Caused by io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/packageName/files/file': Top ref outside file (size = 268484608). top_ref[0]: FF50828, top_ref[1]: 100473C0, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 1. (Top ref outside file (size = 268484608). top_ref[0]: FF50828, top_ref[1]: 100473C0, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 1) (/data/data/packageName/files/file) in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101
at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(OsSharedRealm.java)
at io.realm.internal.OsSharedRealm.
at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:241)
at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:231)
at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:319)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:282)
at io.realm.Realm.getInstance(Realm.java:378)
at in.bizanalyst.utils.RealmUtils.getRealm(RealmUtils.java:65)
at in.bizanalyst.utils.RealmUtils.getCurrentRealm(RealmUtils.java:76)
at in.bizanalyst.activity.MainActivity.onCreate(MainActivity.java:201)
at android.app.Activity.performCreate(Activity.java:6955)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Not reproducable
Version of Realm and tooling
Realm version(s): 5.4.1
Realm Sync feature enabled: Yes
Android Studio version: Yes
Android Build Tools version: 27.0.3
Gradle version: 3.4.1
Which Android version and device(s): All
@ankursharma234 Are you seeing this on multiple devices? In that case, which ones?
Also are you by any chance moving Realm files around yourself? The error indicates that the file is "shorter" than expected.
@cmelchior
Devices:
samsung - 57%
Xiaomi - 12%
OnePlus - 11%
OPPO - 4%
No realm file is not moved by any chance. And what do you mean by file is shorter than expected
@ankursharma234 Do you have similar stack traces from these devices? We would be very interested in knowing the exact values from those exceptions as that can help us narrow down where this might occur.
Also if you know the exact device, that would be extremely helpful as well. Especially the device where this is most common.
When I say the file appears to "short", it is because the top_refs defines an offset into the file that indicates where it "starts", but that offset is outside the actual size of the file. This should of course not be possible, but we still haven't been able to reproduce this.
I have a similar issue:
Samples of different devices:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{....library.LibraryActivity}: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.mycompany/files/librarydb.realm': Top ref outside file (size = 1310720). top_ref[0]: 303150000031878, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 0. (Top ref outside file (size = 1310720). top_ref[0]: 303150000031878, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 0) (/data/data/com.mycompany/files/librarydb.realm) in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101 Kind: ACCESS_ERROR.
Galaxy On5
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{....library.LibraryActivity}: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.mycompany/files/librarydb.realm': Top ref outside file (size = 1703936). top_ref[0]: 303150000142A50, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 0. (Top ref outside file (size = 1703936). top_ref[0]: 303150000142A50, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 0) (/data/data/com.mycompany/files/librarydb.realm) in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101 Kind: ACCESS_ERROR.
LGMP450
Fatal Exception: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.mycompany/files/librarydb.realm': Top ref outside file (size = 1310720). top_ref[0]: 303150000024E60, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 0. (Top ref outside file (size = 1310720). top_ref[0]: 303150000024E60, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 0) (/data/data/com.mycompany/files/librarydb.realm) in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101
Oneplus 2
Fatal Exception: java.lang.RuntimeException: Unable to create application com.mycompany.MainApplication: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.mycompany/files/userdb.realm': Top ref outside file (size = 36864). top_ref[0]: 3031500000083E8, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 0. (Top ref outside file (size = 36864). top_ref[0]: 3031500000083E8, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 0) (/data/data/com.mycompany/files/userdb.realm) in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101 Kind: ACCESS_ERROR.
H8216
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{....library.LibraryActivity}: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.mycompany/files/librarydb.realm': Top ref outside file (size = 1310720). top_ref[0]: 303150000036140, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 1. (Top ref outside file (size = 1310720). top_ref[0]: 303150000036140, top_ref[1]: 46020200, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 1) (/data/data/com.mycompany/files/librarydb.realm) in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101 Kind: ACCESS_ERROR.
Galaxy S7
This is now being tracked in Core here: https://github.com/realm/realm-core/issues/3133.
@ankursharma234 Any information you have regarding how the Realms are being opened/manipulated would be very valuable. Especially if you copying Realms from assets, deleting or copying the files. If you can share your RealmConfiguration that would also help.
Caused by io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/in.package/files/090b64fb-3170-4266-9af7-2d3aed04bc8b': Top ref outside file (size = 268484608). top_ref[0]: FF50828, top_ref[1]: 100473C0, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 1. (Top ref outside file (size = 268484608). top_ref[0]: FF50828, top_ref[1]: 100473C0, mnemonic: 54 2D 44 42, fmt[0]: 9, fmt[1]: 9, flags: 1) (/data/data/in.package/files/090b64fb-3170-4266-9af7-2d3aed04bc8b)
From #6304
@cmelchior Here is my realm configuration
private static RealmConfiguration getRealmConfig(final Context context, final String id) {
RealmConfiguration config = configByCompany.get(id);
if (null == config) {
config = new RealmConfiguration.Builder()
.name(id)
.schemaVersion(62)
.migration(new Migration())
.encryptionKey(KeystoreUtils.getEncryptionKey(context, id))
.build();
configByCompany.put(id, config);
}
return config;
}
public synchronized static Realm getRealm(final String id) {
final Context context = BizAnalystApplication.getInstance().getApplicationContext();
final RealmConfiguration config = getRealmConfig(context, id);
return Realm.getInstance(config);
}
And no, the files are not moved or copied nor they are deleted
Got the same stuff here - attached the stack traces.
com.app_issue_crash_5CD0B748033400010F4EC84DCA59D6AE_DNE_5_v2.txt
I'm also getting similar crashes. I'm using multi process, not sure if it is relevant.
Realm version: 5.14.0
@jpmcosta Please log all details if it's the same exception. In cases where it's not immediately reproducible, the more details we have the better.
@bmunkholm unfortunately the bug was already removed from my issue tracker. I didn't share it, because I thought it was irrelevant. I will take that into consideration in future reports. Sorry about that.
Should be fixed in 6.0.1 (not released yet), but 6.0.1-SNAPSHOT should be available. See https://github.com/realm/realm-java/blob/master/README.md#using-snapshots