realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Random crashes with encrypted realm. #7652

Closed yul13th closed 1 year ago

yul13th commented 2 years ago

How frequently does the bug occur?

Sometimes

Description

Application constantly crashes in random transactions.

Stacktrace & log output

2022-02-26 15:47:15.802 6088-6465/packageAPP E/REALM: uncaught exception in notifier thread: N5realm5_impl17TransactLogParser14BadTransactLogE: Bad transaction log
2022-02-26 15:47:15.807 6088-6465/packageAPP E/libc++abi: terminating with uncaught exception of type realm::_impl::TransactLogParser::BadTransactLog: Bad transaction log
2022-02-26 15:47:15.811 6088-6465/packageAPP A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 6465 (packageAPP), pid 6088 (packageAPP)

Can you reproduce the bug?

Yes, sometimes

Reproduction Steps

use the RealmConfiguration Builder with an encryptionKey then it will crash in Radom transactions using mostly copyToRealmOrUpdate

realmConfiguration = RealmConfiguration.Builder().encryptionKey(key)
        .name("nameDB")
        .allowWritesOnUiThread(true)
        .modules(RealmModule())
        .deleteRealmIfMigrationNeeded()
        .schemaVersion(1).build()
    Realm.setDefaultConfiguration(realmConfiguration)

example transactions

  Realm.getInstance(realmConfiguration)?.let {
            it.beginTransaction()
            val results = it.where(className::class.java)
                .isNotNull(name).findAll()
            results.load()
            results.deleteAllFromRealm()
            it.copyToRealmOrUpdate(list)
            it.commitTransaction()
            it.close()
        }

Version

10.10.1

What SDK flavour are you using?

Local Database only

Are you using encryption?

Yes, using encryption

Platform OS and version(s)

ANDROID 12

Build environment

Android Studio Bumblebee | 2021.1.1 Patch 2 tools.build:gradle: 7.1.2 
kotlin-gradle-plugin: 1.6.10

clementetb commented 2 years ago

@yul13th do you have access to the affected Realm db file? We have found a potential issue when working with encrypted realms that can end up with a corrupt the database.

realm/realm-core#5174

paolo-ermit commented 2 years ago

I've the same problem. But opening the file after a crash with Realm studio the file is readable, it doesn't seem to be corrupted. Problem is happening with version 10.10.1 and not with versione 10.9.1

sideprojecteu commented 2 years ago

I also have the same problem with encrypted realm after updating to 10.10.1. It was fine in 10.9.0 and previous versions. I do not have access to db file.

yul13th commented 2 years ago

@yul13th do you have access to the affected Realm db file? We have found a potential issue when working with encrypted realms that can end up with a corrupt the database.

realm/realm-core#5174

I can't access the file... when the app crashes the device will ask to clean cache and then the app will work for a litlle while then it will happen again and the cycles repeat. So yes, I think it is possible that the file is getting corrupted.

finnschiermer commented 2 years ago

@clementetb as this is a newcomer happening only after a recent release (if I read it correctly), it is likely not related to the problem in https://github.com/realm/realm-core/issues/5174

clementetb commented 2 years ago

@finnschiermer I see, it must be unrelated as it is an issue present since the first implementation.

@paolo-ermit @sideprojecteu @yul13th we could not replicate the issue with the information provided. Are you able to reproduce it constantly? Is it affecting an unique device? Could you write and share an example project that reproduces the issue?

mattylase commented 2 years ago

Wanted to add my voice to the chorus here. We somewhat recently upgraded to Realm 10.11.0. We didn't see any problems locally or in Crashlytics, but found a huge amount of problems are coming through the Play Console's reporting feature.

Screen Shot 2022-06-29 at 2 09 00 PM

,

mattylase commented 2 years ago

The only logs I have access to are from a non-technical coworker who happened to see the issue on their device. I'm not 100% sure it's related to encryption, but we are using encrypted Realm. I can't provide any repro steps or examples, as all reports are from the field of our app crash looping.

2022-06-29 13:36:38.124 16282-16282/? E/com.ourapp.sm: Not starting debugger since process cannot load the jdwp agent.
2022-06-29 13:36:38.339 16282-16282/? A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 16282 (com.ourapp.sm), pid 16282 (com.ourapp.sm)
2022-06-29 13:36:38.610 16360-16360/? A/DEBUG: Cmdline: com.ourapp.sm
2022-06-29 13:36:38.610 16360-16360/? A/DEBUG: pid: 16282, tid: 16282, name: com.ourapp.sm  >>> com.ourapp.sm <<<
2022-06-29 13:36:38.610 16360-16360/? A/DEBUG:       #01 pc 000000000039ccc4  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.610 16360-16360/? A/DEBUG:       #02 pc 000000000039ceec  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.610 16360-16360/? A/DEBUG:       #03 pc 000000000039cd7c  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.610 16360-16360/? A/DEBUG:       #04 pc 000000000039cd14  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (std::terminate()+56) (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.610 16360-16360/? A/DEBUG:       #05 pc 00000000003b837c  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.610 16360-16360/? A/DEBUG:       #06 pc 00000000004ba69c  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.610 16360-16360/? A/DEBUG:       #07 pc 0000000000622398  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #08 pc 0000000000626e94  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #09 pc 00000000005b4ff0  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #10 pc 00000000004240ac  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #11 pc 000000000042d714  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #12 pc 00000000004686e0  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #13 pc 0000000000468120  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #14 pc 000000000048fe50  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #15 pc 00000000004693b0  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #16 pc 00000000003ea8d8  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/base.apk!librealm-jni.so (Java_io_realm_internal_OsSharedRealm_nativeGetSharedRealm+132) (BuildId: 8233dde6fe4a96bdf9f1846a1e12689b58a893c1)
2022-06-29 13:36:38.611 16360-16360/? A/DEBUG:       #19 pc 00000000024a08d8  /data/app/~~l-fpfTv3JOEU-rNFGVXnvA==/com.ourapp.sm-OzTGXILDWCH9vNJbAAejRg==/oat/arm64/base.vdex
clementetb commented 1 year ago

@mattylase we are looking into the log you have shared in this issue: https://github.com/realm/realm-java/issues/7695

clementetb commented 1 year ago

Closing due to inactivity.