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

Invalidated frozen RealmResults #7693

Closed andriy-svirskyy closed 1 year ago

andriy-svirskyy commented 2 years ago

How frequently does the bug occur?

Seen once

Description

Android app, realm plugin 10.9.0, 10.11.0

Iterating the database:

try(@NonNull Realm database = Realm.getDefaultInstance()) {
    @NonNull final RealmResults<Item> items = database.where(Item.class).findAll().freeze();

    for(@NonNull final Item current: items) {// CRASH OBSERVED HERE
        ...
    }
}

Observing crash "Access to invalidated Results objects" in frozen RealmResults object. I don't expect the RealmResults instance to get invalidated inside the iteration loop.

Stacktrace & log output

06-21 17:35:14.103 E/AndroidRuntime(31988): java.lang.IllegalStateException: Access to invalidated Results objects in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 149
06-21 17:35:14.103 E/AndroidRuntime(31988):     at io.realm.internal.OsResults.nativeSize(Native Method)
06-21 17:35:14.103 E/AndroidRuntime(31988):     at io.realm.internal.OsResults.size(OsResults.java:398)
06-21 17:35:14.103 E/AndroidRuntime(31988):     at io.realm.internal.OsResults$Iterator.hasNext(OsResults.java:78)

Can you reproduce the bug?

Not deliberately. It observed in the background service which executed every hour, and some executions succeeded.

Reproduction Steps

No response

Version

10.9.0, 10.11.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Android 8.0

Build environment

Android Studio version: 2021.2.1 Android Build Tools version: 30.0.3 Gradle version: 3.3.3

sync-by-unito[bot] commented 1 year ago

➤ Clemente Tort Barbero commented:

Can you reproduce it consistently? Could you share a project sample to reproduce at our end?

andriy-svirskyy commented 1 year ago

➤ Clemente Tort Barbero commented:

Can you reproduce it consistently? Could you share a project sample to reproduce at our end?

Still unable to reproduce it.

edualonso commented 1 year ago

Hi @andriy-svirskyy we cannot assess what is going on with the information you provide us. Do you see a pattern on the crashes? What is the frequency of said crashes? It would also be very helpful if you could provide a sample project similar to the one that has the problem so that we could debug it. But in any case we would need a reproduction case to be able to help you with this.

andriy-svirskyy commented 1 year ago

Hi @andriy-svirskyy we cannot assess what is going on with the information you provide us. Do you see a pattern on the crashes? What is the frequency of said crashes? It would also be very helpful if you could provide a sample project similar to the one that has the problem so that we could debug it. But in any case we would need a reproduction case to be able to help you with this.

I've seen this crash just once.

andriy-svirskyy commented 1 year ago

After checking logs I found that this bug happens periodically, have accordingly updated the description.

rorbech commented 1 year ago

@andriy-svirskyy As already mentioned it is not possible for us to guide on this without further information about the overall usage of realm in your app. Please provide some more details about what you are trying to achieve and all observed patterns around when the issue happens

clementetb commented 1 year ago

Closing due to inactivity.