firebase-android-sdk: OverlappingFileLockException crashes with up to date libraries versions

  • Android Studio version: 3.6.3
  • Firebase Components & versions: com.google.firebase:firebase-core 17.4.0 com.google.firebase:firebase-analytics 17.4.0 com.google.firebase:firebase-messaging 20.1.6 com.crashlytics.sdk.android:crashlytics 2.10.1 com.google.firebase:firebase-dynamic-links 19.1.0 com.google.firebase:firebase-database 19.3.0 com.google.firebase:firebase-config 19.1.4

Describe the problem

After releasing a new version ni production with up to date Firebase libraries we have many new crashes (Google Play developer console & Firebase Crashlytics).

Steps to reproduce:

Up-to-date libraries versions. Notes

Relevant Code:

Fatal Exception: java.nio.channels.OverlappingFileLockException
       at sun.nio.ch.SharedFileLockTable.checkList(SharedFileLockTable.java:255)
       at sun.nio.ch.SharedFileLockTable.add(SharedFileLockTable.java:152)
       at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1080)
       at java.nio.channels.FileChannel.lock(FileChannel.java:1053)
       at com.google.firebase.installations.CrossProcessLock.acquire(CrossProcessLock.java:52)
       at com.google.firebase.installations.FirebaseInstallations.getPrefsWithGeneratedIdMultiProcessSafe(FirebaseInstallations.java:376)
       at com.google.firebase.installations.FirebaseInstallations.doNetworkCall(FirebaseInstallations.java:327)
       at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationInternal$0(FirebaseInstallations.java:323)
       at com.google.firebase.installations.FirebaseInstallations$$Lambda$5.run(FirebaseInstallations.java:4)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at java.lang.Thread.run(Thread.java:764)

Another kind of new crashes we have that seems also related (FirebaseInstallations):

Fatal Exception: java.lang.Error: java.io.IOException: Bad file descriptor
       at sun.nio.ch.FileKey.create(FileKey.java:46)
       at sun.nio.ch.SharedFileLockTable.<init>(SharedFileLockTable.java:120)
       at sun.nio.ch.FileLockTable.newSharedFileLockTable(FileLockTable.java:47)
       at sun.nio.ch.FileChannelImpl.fileLockTable(FileChannelImpl.java:993)
       at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1015)
       at java.nio.channels.FileChannel.lock(FileChannel.java:875)
       at com.google.firebase.installations.CrossProcessLock.acquire(CrossProcessLock.java:52)
       at com.google.firebase.installations.FirebaseInstallations.getPrefsWithGeneratedIdMultiProcessSafe(FirebaseInstallations.java:376)
       at com.google.firebase.installations.FirebaseInstallations.doNetworkCall(FirebaseInstallations.java:327)
       at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationInternal$0(FirebaseInstallations.java:323)
       at com.google.firebase.installations.FirebaseInstallations$$Lambda$5.run(FirebaseInstallations.java)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:760)
Caused by java.io.IOException: Bad file descriptor
       at sun.nio.ch.FileKey.init(FileKey.java)
       at sun.nio.ch.FileKey.create(FileKey.java:44)
       at sun.nio.ch.SharedFileLockTable.<init>(SharedFileLockTable.java:120)
       at sun.nio.ch.FileLockTable.newSharedFileLockTable(FileLockTable.java:47)
       at sun.nio.ch.FileChannelImpl.fileLockTable(FileChannelImpl.java:993)
       at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1015)
       at java.nio.channels.FileChannel.lock(FileChannel.java:875)
       at com.google.firebase.installations.CrossProcessLock.acquire(CrossProcessLock.java:52)
       at com.google.firebase.installations.FirebaseInstallations.getPrefsWithGeneratedIdMultiProcessSafe(FirebaseInstallations.java:376)
       at com.google.firebase.installations.FirebaseInstallations.doNetworkCall(FirebaseInstallations.java:327)
       at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationInternal$0(FirebaseInstallations.java:323)
       at com.google.firebase.installations.FirebaseInstallations$$Lambda$5.run(FirebaseInstallations.java)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:760)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 52 (23 by maintainers)

Most upvoted comments

@JeremyR34 Really sorry for the inconvenience. I have raised the priority of this issue with my team and should have some update by early next week. I understand that catching the OverlappingFileLockException is a quick fix. However, we need to evaluate what the impact of catching this exception will be on the Firebase Installation service.

Thanks for sharing the timelines with us. I will keep that in mind when addressing this issue.

I saw a fix in firebase-installations:16.3.1 that try to catch the error but actually failed? the OverlappingFileLockException not match IOException or Error. https://github.com/firebase/firebase-android-sdk/pull/1521/commits/c3d4b09c11fdda469d34796ad701a5e47ad1426c

image

image

Any update about this issue? Already crashed about 3000+ now, any firebase compents we used all updated to the lastest version, but issue still there.

implementation 'com.google.firebase:firebase-analytics:17.5.0'  
implementation 'com.google.firebase:firebase-messaging:20.2.4'  
implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
implementation 'com.google.firebase:firebase-perf:19.0.8'    

image

For information I do not call FirebaseInstanceId.getInstance().getId() in my projects.

Hi @ankitaj224 I understand it is a difficult error to reproduce and resolve.

Yes. I do call FirebaseInstanceId.getInstance().getId() in Project A, which is the project which gives the OverlappingFileLockException error. I call the addOnCompleteListener to get an updated device token. I do not call it in Project B because I have not updated that project as yet. It still uses FirebaseInstanceId.getInstance().getToken() to get an updated device token.

Hi @ankitaj224. I would like to provide the following information regarding my recent experience with this OverlappingFileLockException error. Maybe it will help in finding its resolution.

I have one project (Project A) with the following dependencies and versions: classpath ‘com.google.firebase:perf-plugin:1.3.1’ implementation ‘com.google.firebase:firebase-messaging:20.2.1’ implementation ‘com.google.firebase:firebase-analytics:17.4.3’ implementation ‘com.google.firebase:firebase-ads:19.2.0’ implementation ‘com.google.firebase:firebase-perf:19.0.7’

I released and encountered the error in question.

I reverted Project A to now have the following dependencies and versions: classpath ‘com.google.firebase:perf-plugin:1.3.0’ implementation ‘com.google.firebase:firebase-messaging:19.0.1’ implementation ‘com.google.firebase:firebase-core:17.0.0’ implementation ‘com.google.firebase:firebase-ads:18.0.0’ implementation ‘com.google.firebase:firebase-perf:18.0.1’

I released. It has been some weeks and so far I have not encountered the error in question.

I have another project (Project B) I released this project with the following dependencies and versions (similar to the versions for Project A when it experienced the error): classpath ‘com.google.firebase:perf-plugin:1.3.1’ implementation ‘com.google.firebase:firebase-analytics:17.4.3’ implementation ‘com.google.firebase:firebase-messaging:20.2.1’ implementation ‘com.google.firebase:firebase-perf:19.0.7’

However, it has been a week since I released Project B and so far I have not encountered the error in question.

Both projects have users using Android 7 and 8. Important to note Project A is used far more than Project B.

For some reason the same dependencies and versions in Project A give this OverlappingFileLockException error but in Project B do not.

Hopefully this information is of some assistance

@JeremyR34 Thanks for the stack traces and identifying the Android versions. It’s not obvious to me why we are still seeing the OverlappingException. I am trying to reproduce the issue based on the above information. I will keep this thread posted about my findings.

I will. I should release a new version in the next few days so I will be able to try the fix.

No I don’t think so. I have less java.lang.Error: java.io.IOException: Bad file descriptor than OverlappingFileLockException exceptions and Crashlytics shows different device models. But both only happened on Android 7 & 8.

OverlappingFileLockException: image image

java.lang.Error: java.io.IOException: Bad file descriptor image image

@JeremyR34 : Thank you for the bug report! It’s late now in the Bay Area, but we will look into this tomorrow!