realm / realm-java

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

Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. transaction_ended Exception backtrace: <backtrace not supported on this platform> in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 492 #7221

Open Ar-Shak opened 3 years ago

Ar-Shak commented 3 years ago

Goal

Android app with latest realm (10.0.1) & even older version crashes with the error mentioned in the stack trace provided by Firebase Crashlytics. I thought the latest version might have fixed this issue. Also, the crash doesn't point to any of the files related to the project and I'm unable to reproduce this issue.

Actual Results

Stack trace provided by Firebase Crashlytics:

Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. transaction_ended Exception backtrace:

in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 492 at io.realm.internal.OsResults.nativeEvaluateQueryIfNeeded(OsResults.java) at io.realm.internal.OsResults.load(OsResults.java:701) at io.realm.internal.OsResults.freeze(OsResults.java:329) at io.realm.RealmResults.freeze(RealmResults.java:603) at io.realm.rx.RealmObservableFactory$6$1.onChange(RealmObservableFactory.java:196) at io.realm.rx.RealmObservableFactory$6$1.onChange(RealmObservableFactory.java:192) at io.realm.internal.ObservableCollection$RealmChangeListenerWrapper.onChange(ObservableCollection.java:39) at io.realm.internal.ObservableCollection$CollectionObserverPair.onChange(ObservableCollection.java:20) at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:64) at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:54) at io.realm.internal.ObserverPairList.foreach(ObserverPairList.java:109) at io.realm.internal.OsResults.notifyChangeListeners(OsResults.java:675) at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:336) at android.os.Looper.loop(Looper.java:174) at android.app.ActivityThread.main(ActivityThread.java:7397) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935) #### Steps & Code to Reproduce Unable to reproduce the issue. I have seen multiple devices (including my personal device) crash. I could only read the stack trace from Firebase Crashlytics and it doesn't point to any of the files within the project. #### Version of Realm and tooling Realm version(s): 10.0.1 Realm Sync feature enabled: No Android Studio version: 4.1.1 Android Build Tools version: 30.0.2 Gradle version: 6.5 Which Android version and device(s): Samsung Galaxy Note 9 – Android version 10 Xiaomi Mi 9T Pro – Android version 10 LG Stylo 5 – Android version 10 Samsung Galaxy Note 10+ – Android version 10 Realme narzo 20 Pro – Android version 10 Nokia 5.3 – Android version 10 There are more devices with older android versions, but unfortunately crashlytics is not allowing to view crashes past 90 days. ![](https://user-images.githubusercontent.com/48918690/100620392-63cb6980-3344-11eb-8062-f0dbf40e763e.png)
rorbech commented 3 years ago

Thanks for the report. I don't have an immediate explanation for this, so I will have to investigate a bit to answer it properly.

edualonso commented 3 years ago

Maybe related to https://github.com/realm/realm-java/issues/7250.

cmelchior commented 3 years ago

There is a chance this might be fixed by Realm Java 10.3.0. Which will be released shortly. At least this was in the changelog: https://github.com/realm/realm-core/blob/master/CHANGELOG.md#1033-release-notes

Fix a race condition which would lead to "uncaught exception in notifier thread: N5realm15InvalidTableRefE: transaction_ended" and a crash when the source Realm was closed or invalidated at a very specific time during the first run of a collection notifier (#3761, since v6.0.0).
Ar-Shak commented 3 years ago

I hope the above version fixes the issue, as I'm on the verge of moving away from Realm due to this issue.

rorbech commented 3 years ago

@arshak-kahnputers Have you been able to test this with 10.3.0 (https://github.com/realm/realm-java/blob/master/CHANGELOG.md)?

Ar-Shak commented 3 years ago

@rorbech I have updated the library, so far haven't noticed any crash. Will update if I were to see any on Crashlytics.

rorbech commented 3 years ago

@arshak-kahnputers Thanks for the feedback. I will close the issue for now. Please feel free to repost if you have new observations.

Ar-Shak commented 3 years ago

@rorbech The issue still persists on 10.3.0 which happened on LGE Stylo 6 running Android 10 which doesn't point to any Project files. The exception title text seemed to have changed but the line number and the remaining lines looks similar. Please check the attached screenshot.

Here's the stack trace: Fatal Exception: java.lang.IllegalStateException: Access to invalidated Results objects in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 492 at io.realm.internal.OsResults.nativeEvaluateQueryIfNeeded(OsResults.java) at io.realm.internal.OsResults.load(OsResults.java:701) at io.realm.internal.OsResults.freeze(OsResults.java:329) at io.realm.RealmResults.freeze(RealmResults.java:600) at io.realm.rx.RealmObservableFactory$6$1.onChange(RealmObservableFactory.java:196) at io.realm.rx.RealmObservableFactory$6$1.onChange(RealmObservableFactory.java:192) at io.realm.internal.ObservableCollection$RealmChangeListenerWrapper.onChange(ObservableCollection.java:39) at io.realm.internal.ObservableCollection$CollectionObserverPair.onChange(ObservableCollection.java:20) at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:64) at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:54) at io.realm.internal.ObserverPairList.foreach(ObserverPairList.java:109) at io.realm.internal.OsResults.notifyChangeListeners(OsResults.java:675) at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:336) at android.os.Looper.loop(Looper.java:174) at android.os.HandlerThread.run(HandlerThread.java:67)

Screenshot 2021-01-26 at 7 43 19 PM

afaucogney commented 3 years ago

We are in the same situation here ! Top Crashlitics Crash : 500 by days. Help would be good !

Firsto commented 3 years ago

Little different message of error at the same line:

Caused by io.realm.exceptions.RealmError: Unrecoverable error. No such object in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 492 at io.realm.internal.OsResults.nativeEvaluateQueryIfNeeded(OsResults.java) at io.realm.internal.OsResults.load(OsResults.java:701) at io.realm.RealmResults.load(RealmResults.java:142) at io.realm.RealmQuery.createRealmResults(RealmQuery.java:2360) at io.realm.RealmQuery.findAll(RealmQuery.java:2039)

cmelchior commented 3 years ago

Hi, we are looking into it, but nothing conclusive yet.

Ar-Shak commented 3 years ago

@cmelchior Please let us know once this issue has been resolved.

I'm commenting on this so that the issue remains open, as it seems that a bot has closed this issue yesterday.

afaucogney commented 3 years ago

@cmelchior Hi any news on this ?

Here is a crash I get close to the issue (but in a Rx context)

Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. transaction_ended
Exception backtrace:
<backtrace not supported on this platform> in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 504
       at io.realm.internal.OsResults.nativeFreeze(OsResults.java)
       at io.realm.internal.OsResults.freeze(OsResults.java:14)
       at io.realm.RealmResults.freeze(RealmResults.java:16)
       at io.realm.rx.RealmObservableFactory$6$1.onChange(RealmObservableFactory.java:20)
       at io.realm.rx.RealmObservableFactory$6$1.onChange(RealmObservableFactory.java:2)
       at io.realm.internal.ObservableCollection$RealmChangeListenerWrapper.onChange(ObservableCollection.java:2)
       at io.realm.internal.ObservableCollection$CollectionObserverPair.onChange(ObservableCollection.java:13)
       at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:2)
       at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:2)
       at io.realm.internal.ObserverPairList.foreach(ObserverPairList.java:41)
       at io.realm.internal.OsResults.notifyChangeListeners(OsResults.java:46)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:336)
       at android.os.Looper.loop(Looper.java:197)
       at android.os.HandlerThread.run(HandlerThread.java:67)

App uses 10.0.4

afaucogney commented 3 years ago

or

Fatal Exception: java.lang.IllegalStateException: Access to invalidated Results objects in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 492
       at io.realm.internal.OsResults.nativeEvaluateQueryIfNeeded(OsResults.java)
       at io.realm.internal.OsResults.load(OsResults.java:8)
       at io.realm.internal.OsResults.freeze(OsResults.java:27)
       at io.realm.RealmResults.freeze(RealmResults.java:16)
       at io.realm.rx.RealmObservableFactory$6$1.onChange(RealmObservableFactory.java:20)
       at io.realm.rx.RealmObservableFactory$6$1.onChange(RealmObservableFactory.java:2)
       at io.realm.internal.ObservableCollection$RealmChangeListenerWrapper.onChange(ObservableCollection.java:2)
       at io.realm.internal.ObservableCollection$CollectionObserverPair.onChange(ObservableCollection.java:13)
       at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:2)
       at io.realm.internal.ObservableCollection$Callback.onCalled(ObservableCollection.java:2)
       at io.realm.internal.ObserverPairList.foreach(ObserverPairList.java:41)
       at io.realm.internal.OsResults.notifyChangeListeners(OsResults.java:46)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:326)
       at android.os.Looper.loop(Looper.java:181)
       at android.os.HandlerThread.run(HandlerThread.java:65)

What is strange here is how this may happen with freezed object, isn't it ?

shrikantbmali commented 2 years ago

any update here?

bmunkholm commented 2 years ago

@shrikantbmali Are you experiencing anything similar? Could you please post all details? Are you in any way able to reproduce?

shrikantbmali commented 2 years ago

@bmunkholm Yes, When I try to create a realm instance in temp folder while I am running my Dotnet core 3.1 app it fails, I can consistently reproduce it. however, I just realized that I am posting of java thread. my bad, but the log is exactly the same.

bmunkholm commented 2 years ago

@shrikantbmali That's interesting - could you please create a new issue in realm/realm-dotnet ? All details in terms how we could possibly reproduce it would be appreciated. Feel free to reference this issue as well as possibly related. Thanks!

silicon-pranit commented 2 years ago

Any update on this one? This is our one of the top crashes.

This issue has 59931 crash events affecting 11803 users

` Exception io.realm.exceptions.RealmError: Unrecoverable error. transaction_ended Exception backtrace:

in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 517 at io.realm.internal.OsResults.nativeEvaluateQueryIfNeeded (OsResults.java) at io.realm.internal.OsResults.load (OsResults.java:745) at io.realm.RealmResults.load (RealmResults.java:152) at io.realm.RealmQuery.createRealmResults (RealmQuery.java:2850) at io.realm.RealmQuery.findAll (RealmQuery.java:2465) ` Realm: v10.11.0 Let me know if you guys need anything else from our end to debug/fix this issue.
edualonso commented 2 years ago

@silicon-pranit your issue might not necessarily be the same as the one originally reported in this ticket. I would suggest you create another ticket and provide us with a full stack trace, including any potential native crashes following the format shown in https://developer.android.com/ndk/guides/ndk-stack

dvdciri commented 1 year ago

We are also noticing this issues in production:

io.realm.exceptions.RealmError: Unrecoverable error. transaction_ended
Exception backtrace:
<backtrace not supported on this platform> in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 529
    at io.realm.internal.OsResults.nativeFreeze
    at io.realm.internal.OsResults.freeze
    at io.realm.RealmResults.freeze
    at io.realm.rx.RealmObservableFactory$6$1.onChange
    at io.realm.rx.RealmObservableFactory$6$1.onChange
    at io.realm.internal.ObservableCollection$RealmChangeListenerWrapper.onChange
    at io.realm.internal.ObservableCollection$CollectionObserverPair.onChange
    at io.realm.internal.ObservableCollection$Callback.onCalled
    at io.realm.internal.ObservableCollection$Callback.onCalled
    at io.realm.internal.ObserverPairList.foreach
    at io.realm.internal.OsResults.notifyChangeListeners
    at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
    at android.os.MessageQueue.next(MessageQueue.java:335)
    at android.os.Looper.loopOnce(Looper.java:161)
    at android.os.Looper.loop(Looper.java:288)
    at android.os.HandlerThread.run(HandlerThread.java:67)