Bugs: Crash is happening suddenly in the app
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x248 in tid 12164 (com.x.dev)
[ 03-15 23:55:42.919 375: 375 W/ ]
debuggerd: handling request: pid=12164 uid=10576 gid=10576 tid=12164
Describe your current debugging efforts.
The issue happens suddenly. Mostly when I delete something from Realm.
final Item Item = realmUI.where(Item.class).equalTo("id", Id).findFirst();
Realm realm = Realm.getDefaultInstance();
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm transactionRealm) {
Item.deleteFromRealm();
}
});
realm.close();
Realm version(s): ?
2.3.1
Realm sync feature enabled: yes/no
no
Android Studio version:?
2.3
Which Android version and device:?
Nexus6p android v7.1
v2.3.2, can you try it?Execute the query inside the transaction
the error is not happening anymore in v3.0 , will keep you up to date in case happened again.
if I was right, then results integration forces the RealmResults to be up to date via realm.beginTransaction() (part of executeTransaction() and therefore you don't need to query inside the transaction to force the RealmResults to be up to date
If I was off, then who knows :smile:
@Zhuinden It should throw an invalid row exception before instead of native crash ...
But anyway, good not know it is not happening in 3.0.0. I am closing this now. Let us know if it happened again.
It happened to me on a Sony Xperia Z1 device with, Realm 3.1.3 version. I was quick sliding betfeen fragments. and it is crashed.
@guness well what do your fragments do?
@Zhuinden I have fragments within a ViewPager.
3 of them is using lists with Realm adapter. one is using single realm object to fill details.
Each time I slide between fragments, app first fills the list/details and send a network request then updates data using Realm. (Adapters later take care of the rest).
I was crazy going between fragments in order to reproduce another error, but hit this one.
it is not reproducible easily.
Hello, the error comes up again with me while trying to delete an object from realm:
Realm realm = Realm.getDefaultInstance();
final Comment comment = realm.where(Comment.class).equalTo("id", commentId).findFirst();
if (comment != null) {
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
comment.deleteFromRealm();
}
});
}
realm.close();
I also tried to delete it with
realm.beginTransaction();
comment.deleteFromRealm();
realm.commitTransaction();
realm.close();
but also same error happened.
@beeender also can be reproducible
Version of Realm and tooling
Realm version(s): ?
3.1.3
Realm sync feature enabled: yes/no
no
Android Studio version:?
2.3
Which Android version and device:?
Nexus6p android v7.1
Realm realm = Realm.getDefaultInstance();
RealmResults<Comment> comment = realm.where(Comment.class).equalTo("id",commentId).findAll();
if (comment != null) {
if (comment.isValid()) {
realm.beginTransaction();
comment.deleteFirstFromRealm();
realm.commitTransaction();
}
}
realm.close();
Execute the query inside the transaction. Also make sure the results is not empty.
Although there should probably be a better check on Realm side.
@Zhuinden your suggestion didn't solve the issue.
UPDATE: I have checked if the comment object is being deleted from the database using RealmBrowser and it seems the native crash is happening after the object deletion from DB.
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
RealmResults<Comment> comment = realm.where(Comment.class).equalTo("id",commentId).findAll();
if(!comment.isEmpty()) {
comment.deleteFirstFromRealm();
}
realm.commitTransaction();
realm.close();
Additional information to add, there is a relationship between comments and posts where each post has Realmlist <Comment>. What I want to do here is to delete a comment found in DB for that post.
@mhdtouban the code I posted should work.
But you can also try comment.get(0).deleteFromRealm() as well, although it shouldn't have different behavior.
@Zhuinden I tried all possibilities above but am still getting this annoying native crash.Thanks anyway
@mhdtouban in that case you might want to set RealmLog.setLevel(LogLevel.TRACE) or something similar, and whatever happens before the crash should be posted here from the log; I have no idea how to read it, but Realm people do :smile:
here is the stack trace
05-01 22:51:41.798 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsClosed 547610388352
05-01 22:51:41.798 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsClosed 547610388352
05-01 22:51:41.798 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsClosed 547610388352
05-01 22:51:41.798 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_Collection_nativeCreateResults
05-01 22:51:41.803 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsClosed 547610388352
05-01 22:51:41.803 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_Collection_nativeIsValid 547102673792
05-01 22:51:41.803 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsClosed 547610388352
05-01 22:51:41.803 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeBeginTransaction 547610388352
05-01 22:51:41.803 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeGetVersion 547610388352
05-01 22:51:41.803 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsClosed 547610388352
05-01 22:51:41.804 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsInTransaction 547610388352
05-01 22:51:41.804 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_Collection_nativeDeleteFirst 547102673792
05-01 22:51:41.804 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsClosed 547610388352
05-01 22:51:41.804 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeCommitTransaction 547610388352
05-01 22:51:41.819 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsClosed 547610388352
05-01 22:51:41.819 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_SharedRealm_nativeIsClosed 547610388352
05-01 22:51:41.819 20320-20320/com.topshou.dev V/REALM_JNI: --> Java_io_realm_internal_UncheckedRow_nativeIsNull 547110531360
--------- beginning of crash
05-01 22:51:41.819 20320-20320/com.topshou.dev A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x248 in tid 20320 (com.topshou.dev)
[ 05-01 22:51:41.820 385: 385 W/ ]
debuggerd: handling request: pid=20320 uid=10632 gid=10632 tid=20320
@mhdtouban oh you crashed at nativeIsNull meaning that's a duplicate of https://github.com/realm/realm-java/issues/4540
You'll get a proper exception with the snapshot version, please try latest snapshot 3.2.0-SNAPSHOT as per instructions in the readme.md (or since, 3.1.4 release version)
thanks @Zhuinden, this issue was is that I was trying to access a stored object from a list which was deleted. Now am getting an informative exception
java.lang.IllegalStateException: Object is no longer valid to operate on. Was it deleted by another thread?
Glad to hear the pesky bug is finally caught :slightly_smiling_face: