question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

REALM_JNI: flock() failed: Bad file descriptor in io_realm_internal_OsSharedRealm.cpp

See original GitHub issue

We have been struggling with more or less random errors for some time now. Lately I’ve experienced this one during developement:

04-18 12:51:32.263 E/REALM_JNI: jni: ThrowingException 5, flock() failed: Bad file descriptor in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 126, .
    Exception has been thrown: Unrecoverable error. flock() failed: Bad file descriptor in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 126
04-18 12:51:32.270 E/AndroidRuntime: FATAL EXCEPTION: SyncAdapterThread-3
    Process: com.example.app, PID: 12352
    io.realm.exceptions.RealmError: Unrecoverable error. flock() failed: Bad file descriptor in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 126
        at io.realm.internal.OsSharedRealm.nativeBeginTransaction(Native Method)
        at io.realm.internal.OsSharedRealm.beginTransaction(OsSharedRealm.java:269)
        at io.realm.BaseRealm.beginTransaction(BaseRealm.java:401)
        at io.realm.Realm.beginTransaction(Realm.java:146)
        at io.realm.Realm.executeTransaction(Realm.java:1403)
        at com.example.app.sync.SyncAdapter.syncCars(SyncAdapter.kt:1266)
        at com.example.app.sync.SyncAdapter.syncComplete(SyncAdapter.kt:140)
        at com.example.app.sync.SyncAdapter.onPerformSync(SyncAdapter.kt:101)
        at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:321)

Note: The sync adapter framework runs onPerformSync() on a background thread, so you don’t have to set up your own background processing.

The code of the SyncAdapter wasn’t changed for quite a while. At the specific line, there is just an {{realm.executeTransaction { … }}}.

Can you guys read anything from the stack trace? What’s causing this crash?

Version of Realm and tooling

Realm version(s): 5.0.0

Realm sync feature enabled: no

Android Studio version: 3.1.1

Which Android version and device: Pixel 2 (Android 8.1.0)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cmelchiorcommented, Apr 30, 2018

Hi @MariusBoepple Thank you very much for this. I’ll run this past our Core people in order to determine if this can happen in other scenarios than accidentially deleting the Realm file

0reactions
sync-by-unito[bot]commented, Nov 10, 2021

➤ Brian Munkholm commented:

Closing as outdated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

flock in Perl: Bad file descriptor - Stack Overflow
2) Your error message is incorrect. You say it's already locked even when it isn't. Fixed: #!/usr/bin/perl use strict; use warnings; use Fcntl...
Read more >
IV73852: BAD FILE DESCRIPTOR DUE TO OFSTREAM ... - IBM
The fflush() fails with an ENOSPC error due to the full filesystem, and fclose() returns -1. Even though -1 is returned, the fclose()...
Read more >
flock(2) - Linux manual page - man7.org
An attempt to lock the file using one of these file descriptors may be denied by a lock that the calling process has...
Read more >
flock(2) - Linux man page
An attempt to lock the file using one of these file descriptors may be denied by a lock that the calling process has...
Read more >
How to fix bad file descriptor error in VS Code? "File changes ...
I have vsc version 1.66. I'm getting the following notification: File changes watcher stopped unexpectedly. A reload of the window may ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found