Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BadVersionException #2021

Closed
philipuvarov opened this issue Jan 3, 2016 · 47 comments
Closed

BadVersionException #2021

philipuvarov opened this issue Jan 3, 2016 · 47 comments
Labels

Comments

@philipuvarov
Copy link

philipuvarov commented Jan 3, 2016

Hey, guys. I keep getting this exception. I am using 0.87.1 version of Realm(and I use Realm as a singleton).

My situation looks like this: there is navigation button which starts a fragment, which makes an async query for objects in onStart() method. This exception rises when user spams this navigation button or just makes fast transactions between fragments.

java.lang.Error: io.realm.internal.async.BadVersionException: std::exception in io_realm_internal_TableQuery.cpp line 1262 E/AndroidRuntime: at io.realm.RealmQuery$3.call(RealmQuery.java:1491) E/AndroidRuntime: at io.realm.RealmQuery$3.call(RealmQuery.java:1467) E/AndroidRuntime: at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36) E/AndroidRuntime: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:137) E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) E/AndroidRuntime: at java.lang.Thread.run(Thread.java:856) E/AndroidRuntime: Caused by: io.realm.internal.async.BadVersionException: std::exception in io_realm_internal_TableQuery.cpp line 1262 E/AndroidRuntime: at io.realm.internal.TableQuery.nativeFindAllSortedWithHandover(Native Method) E/AndroidRuntime: at io.realm.internal.TableQuery.findAllSortedWithHandover(TableQuery.java:490) E/AndroidRuntime: at io.realm.RealmQuery$3.call(RealmQuery.java:1480) E/AndroidRuntime: at io.realm.RealmQuery$3.call(RealmQuery.java:1467)  E/AndroidRuntime: at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)  E/AndroidRuntime: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)  E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:137)  E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)  E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)  E/AndroidRuntime: at java.lang.Thread.run(Thread.java:856)

By the way, sometimes my during fast transactions between fragments my app crashes with SIGSEV or just completely freezes without throwing ANR, dunno if it's connected to the BadVersion, but just in case.

@dalinaum
Copy link
Contributor

dalinaum commented Jan 3, 2016

Hello, @Kistamushken

If the the specific version of the async query is not equal to the read lock's version, you can encounter BadVersionException. Is there removeChangeListener() or removeChangeListeners() in onStop() method? I think it has relevance to your problem.

@philipuvarov
Copy link
Author

@dalinaum Yeah, I do have removeChangeListener() in the onStop() method, I also tried removeChangeListener(listener) but it didn't really helped. Btw, can It be relative to the SIGSEV I get from time to time, I mean this thing with RealmChangeListener?

@dalinaum dalinaum removed the Pending label Jan 4, 2016
@nhachicha
Copy link
Collaborator

seems related to #2027

@kneth kneth added the Pending label Jan 12, 2016
@cmelchior
Copy link
Contributor

We have discovered a bug in how we handle queries across threads. This is currently being fixed by: realm/realm-core#1405

@cmelchior cmelchior added T-Bug P1 Blocked This issue is blocked by another issue and removed T-Help Pending labels Jan 21, 2016
@cmelchior
Copy link
Contributor

We have just released 0.87.4 with a potential fix for this. We still haven't been able to reproduce the exact error you are reporting here, but upon investigation found something that appeared to be the root cause. So if you can test with 0.87.4 that would be much appreciated.

@cmelchior cmelchior removed the Blocked This issue is blocked by another issue label Jan 28, 2016
@philipuvarov philipuvarov mentioned this issue Jan 29, 2016
@cmelchior
Copy link
Contributor

Seems fixed according to #2027

@cmelchior cmelchior removed the P1 label Jan 29, 2016
@fuwaneko
Copy link

I have similar error on version 0.87.4:

java.lang.Error: io.realm.internal.async.BadVersionException: std::exception in io_realm_internal_TableQuery.cpp line 1094
at io.realm.RealmQuery$5.call(RealmQuery.java:1847)
at io.realm.RealmQuery$5.call(RealmQuery.java:1817)
at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

Caused by: io.realm.internal.async.BadVersionException: std::exception in io_realm_internal_TableQuery.cpp line 1094
at io.realm.internal.TableQuery.nativeFindWithHandover(Native Method)
at io.realm.internal.TableQuery.findWithHandover(TableQuery.java:438)
at io.realm.RealmQuery$5.call(RealmQuery.java:1829)
at io.realm.RealmQuery$5.call(RealmQuery.java:1817) 
at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:818) 

Occurs randomly on app launch when it performs background network operations with writing results to Realm. On foreground activity I have listeners to Realm updates.

@hohnamkung
Copy link

I'm using Realm v0.87.4 and have a similar crash.

Fatal Exception: java.lang.Error: io.realm.internal.async.BadVersionException: std::exception in io_realm_internal_TableQuery.cpp line 1274
   at io.realm.RealmQuery$4.call(RealmQuery.java:1667)
   at io.realm.RealmQuery$4.call(RealmQuery.java:1642)
   at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)
   at java.util.concurrent.FutureTask.run(FutureTask.java:234)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
   at java.lang.Thread.run(Thread.java:841)
Caused by io.realm.internal.async.BadVersionException: std::exception in io_realm_internal_TableQuery.cpp line 1274
   at io.realm.internal.TableQuery.nativeFindAllMultiSortedWithHandover(TableQuery.java)
   at io.realm.internal.TableQuery.findAllMultiSortedWithHandover(TableQuery.java:498)
   at io.realm.RealmQuery$4.call(RealmQuery.java:1655)
   at io.realm.RealmQuery$4.call(RealmQuery.java:1642)
   at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)
   at java.util.concurrent.FutureTask.run(FutureTask.java:234)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
   at java.lang.Thread.run(Thread.java:841)

@heitorpr
Copy link

heitorpr commented Mar 2, 2016

Hey, im having this issue too. Im using realm: 0.87.5. And this is the stacktrace that fabric got to me.

Crashlytics - Crash - Bad Version

@hohnamkung
Copy link

I'm using Realm v0.87.5, this exception still happening with same stack trace.

@heitorpr
Copy link

heitorpr commented Mar 9, 2016

Any tip to not break the app if this issue happen? like a try catch or something...

@cmelchior
Copy link
Contributor

Hi @heitorpr Unfortunately not. Right now the only work-around is using findAll instead of findAllAsync. A fix is being merged as we speak however: #2397

@heitorpr
Copy link

heitorpr commented Mar 9, 2016

I see... Thanks =).

@hohnamkung
Copy link

Hi Realm team.
We've updated Realm v0.88.0 and still have a BadVersionException problem.

Exception log from fabric is a little different from v0.87.5.
I attached it for your information.

Fatal Exception: java.lang.Error: io.realm.internal.async.BadVersionException: std::exception in io_realm_internal_TableQuery.cpp line 1274
   at io.realm.RealmQuery$4.call(RealmQuery.java:1776)
   at io.realm.RealmQuery$4.call(RealmQuery.java:1751)
   at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)
   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
   at java.lang.Thread.run(Thread.java:841)
Caused by io.realm.internal.async.BadVersionException: std::exception in io_realm_internal_TableQuery.cpp line 1274
   at io.realm.internal.TableQuery.nativeFindAllMultiSortedWithHandover(TableQuery.java)
   at io.realm.internal.TableQuery.findAllMultiSortedWithHandover(TableQuery.java:502)
   at io.realm.RealmQuery$4.call(RealmQuery.java:1764)
   at io.realm.RealmQuery$4.call(RealmQuery.java:1751)
   at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)
   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
   at java.lang.Thread.run(Thread.java:841)

@cmelchior cmelchior added this to the 0.91 milestone May 10, 2016
@dbacinski
Copy link

We were able to reproduce this issue on our devices.

There were breaking changes in 0.90, so we need to do some work in order to upgrade. I will let you know when we will retest it.

@kneth
Copy link
Member

kneth commented May 12, 2016

@dbacinski Did you have a chance to upgrade and rerun your tests?

@cmelchior cmelchior removed this from the 0.91 milestone May 17, 2016
@emanuelez
Copy link
Contributor

@dbacinski We haven't heard from you in 9 days so I'm closing this issue. Please let us know if it needs to be reopened!

@Tomekkk
Copy link

Tomekkk commented Nov 14, 2016

Hi @cmelchior @kneth @emanuelez
I was able to reproduced this bug on 2.0.2
Occurs randomly on opening my app.
I don't know if it is important but in the app I'm using findAllAsync()/findFirstAsync() with asObservable() for querying database.

11-14 12:19:14.507 E: jni: ThrowingException 7, std::exception in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1131, .
11-14 12:19:14.526 E: io.realm.internal.async.BadVersionException: std::exception in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1131
 at io.realm.internal.TableQuery.nativeFindWithHandover(Native Method)
 at io.realm.internal.TableQuery.findWithHandover(TableQuery.java:446)
 at io.realm.RealmQuery$5.call(RealmQuery.java:2124)
 at io.realm.RealmQuery$5.call(RealmQuery.java:2115)
 at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)
 at java.util.concurrent.FutureTask.run(FutureTask.java:237)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
 at java.lang.Thread.run(Thread.java:761)
11-14 12:19:14.583 E: FATAL EXCEPTION: main
  Process: com.my.app, PID: 1540
  java.lang.Error: io.realm.internal.async.BadVersionException: std::exception in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1131
      at io.realm.AndroidNotifier.throwBackgroundException(AndroidNotifier.java:139)
      at io.realm.RealmQuery.closeSharedRealmAndSendEventToNotifier(RealmQuery.java:2201)
      at io.realm.RealmQuery.access$000(RealmQuery.java:62)
      at io.realm.RealmQuery$5.call(RealmQuery.java:2141)
      at io.realm.RealmQuery$5.call(RealmQuery.java:2115)
      at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)
      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
      at java.lang.Thread.run(Thread.java:761)
   Caused by: io.realm.internal.async.BadVersionException: std::exception in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1131
      at io.realm.internal.TableQuery.nativeFindWithHandover(Native Method)
      at io.realm.internal.TableQuery.findWithHandover(TableQuery.java:446)
      at io.realm.RealmQuery$5.call(RealmQuery.java:2124)
      at io.realm.RealmQuery$5.call(RealmQuery.java:2115) 
      at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36) 
      at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
      at java.lang.Thread.run(Thread.java:761)

@ppamorim
Copy link

Hi @cmelchior @kneth @emanuelez
Happening on 2.2.2. This problem appears randomly.
Using Kotlin 1.0.4, LG G2 @ 6.0.1

E: jni: ThrowingException 7, std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1130, .
E: Exception has been throw: std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1130
E: jni: ThrowingException 7, std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1284, .
E: Exception has been throw: std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1284
E: io.realm.internal.async.BadVersionException: std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1130
       at io.realm.internal.TableQuery.nativeFindWithHandover(Native Method)
       at io.realm.internal.TableQuery.findWithHandover(TableQuery.java:436)
       at io.realm.RealmQuery$5.call(RealmQuery.java:2124)
       at io.realm.RealmQuery$5.call(RealmQuery.java:2115)
       at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)
D: Shutting down VM
E: FATAL EXCEPTION: main
   Process: com.tpro.dictate, PID: 22079
   Theme: themes:{default=overlay:com.brit.swiftdark, fontPkg:com.brit.swiftdark, com.android.systemui=overlay:com.brit.swiftdark, com.android.systemui.navbar=overlay:com.brit.swiftdark}
   java.lang.Error: io.realm.internal.async.BadVersionException: std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1130
       at io.realm.AndroidNotifier.throwBackgroundException(AndroidNotifier.java:138)
       at io.realm.RealmQuery.closeSharedRealmAndSendEventToNotifier(RealmQuery.java:2201)
       at io.realm.RealmQuery.access$000(RealmQuery.java:62)
       at io.realm.RealmQuery$5.call(RealmQuery.java:2141)
       at io.realm.RealmQuery$5.call(RealmQuery.java:2115)
       at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)
    Caused by: io.realm.internal.async.BadVersionException: std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1130
       at io.realm.internal.TableQuery.nativeFindWithHandover(Native Method)
       at io.realm.internal.TableQuery.findWithHandover(TableQuery.java:436)
       at io.realm.RealmQuery$5.call(RealmQuery.java:2124)
       at io.realm.RealmQuery$5.call(RealmQuery.java:2115) 
       at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36) 
       at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
       at java.lang.Thread.run(Thread.java:818) 

@Zhuinden
Copy link
Contributor

@ppamorim when #3834 is merged, this issue will probably be fixed along with it

@ppamorim
Copy link

Please, I beg you to do this.

@Zhuinden
Copy link
Contributor

@ppamorim in the meantime, I think a possible solution would be to use findAll instead of findAllAsync and etc. But the pull request I mentioned seems scheduled for 2.4.0.

@ppamorim
Copy link

@Zhuinden I will be fired :D

@Zhuinden
Copy link
Contributor

Okay that's not fun, what is your deadline?

@Zhuinden
Copy link
Contributor

But seriously, if you replace all async query method with sync query methods, then this can be fixed temporarily.

@ppamorim
Copy link

Today, I can't do this change... But I can use a snapshot of the fixed version, what do you think?

@Zhuinden
Copy link
Contributor

The object store results integration is not merged yet.

@ppamorim
Copy link

@Zhuinden Solved?

@wenmagi
Copy link

wenmagi commented Jun 13, 2017

Happening on 2.2.2. The problem happened because I use the method of findFirstAsync after deleting caches of my app.

06-13 16:33:44.145 15438-15835/? E/REALM_JAVA: io.realm.internal.async.BadVersionException: std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1130 at io.realm.internal.TableQuery.nativeFindWithHandover(Native Method) at io.realm.internal.TableQuery.findWithHandover(TableQuery.java:436) at io.realm.RealmQuery$5.call(RealmQuery.java:2124) at io.realm.RealmQuery$5.call(RealmQuery.java:2115) at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) 06-13 16:33:44.170 15438-15468/? E/CrashlyticsCore: Tried to write a fatal exception while no session was open. 06-13 16:33:44.185 15438-15438/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.zhihu.android.alpha, PID: 15438 java.lang.Error: io.realm.internal.async.BadVersionException: std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1130 at io.realm.AndroidNotifier.throwBackgroundException(AndroidNotifier.java:138) at io.realm.RealmQuery.closeSharedRealmAndSendEventToNotifier(RealmQuery.java:2201) at io.realm.RealmQuery.access$000(RealmQuery.java:62) at io.realm.RealmQuery$5.call(RealmQuery.java:2141) at io.realm.RealmQuery$5.call(RealmQuery.java:2115) at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) Caused by: io.realm.internal.async.BadVersionException: std::exception in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1130 at io.realm.internal.TableQuery.nativeFindWithHandover(Native Method) at io.realm.internal.TableQuery.findWithHandover(TableQuery.java:436) at io.realm.RealmQuery$5.call(RealmQuery.java:2124) at io.realm.RealmQuery$5.call(RealmQuery.java:2115)  at io.realm.internal.async.BgPriorityCallable.call(BgPriorityCallable.java:36)  at java.util.concurrent.FutureTask.run(FutureTask.java:237)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)  at java.lang.Thread.run(Thread.java:761) 

@beeender
Copy link
Contributor

@ppamorim @wenmagi We have some fundamental changes for async queries when we introduce the fine grained notifications. This issue should be fixed in the latest version. Please update the Realm to the latest version.

@Zhuinden
Copy link
Contributor

Agreed, Realm 2.x notifications with async queries had oddities, Realm 3.1.4 or Realm 3.3.x+ are much better choice

@stan-ko
Copy link

stan-ko commented Aug 23, 2019

This issue still happens to my app on user devices

Caused by io.realm.internal.async.BadVersionException: std::exception in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 152
       at io.realm.internal.OsResults.nativeSize(OsResults.java)
       at io.realm.internal.OsResults.size + 367(OsResults.java:367)
       at io.realm.OrderedRealmCollectionImpl.size + 341(OrderedRealmCollectionImpl.java:341)
       at io.realm.RealmResults.size + 72(RealmResults.java:72)
       at mypackage.util.UDHelper.getUDs + 84(UDHelper.java:84)

UDHelper has following code:

		final RealmResults<SDocs> registeredDocs = sMainUIRealmInstance.where(SDocs.class).findAll();
		int registeredDocsCount = registeredDocs.size(); // this is line 84 where crash happens

previously it was just check registeredDocs.isEmpty() with absolutely the same crash so I tried to use registeredDocs.size() but no luck. I realize isEmpty() most probably utilizes the same size() method.
Realm is declared in gradle.build as classpath "io.realm:realm-gradle-plugin:5.9.1".

@Zhuinden
Copy link
Contributor

This generally shouldn't happen, but what happens if you put refresh() above it?

@alexneo2003
Copy link

This generally shouldn't happen, but what happens if you put refresh() above it?

hi. i'm have same issue at isEmpty() and size()
refresh() not helping me)
i'm using realm 6.0.0

    io.realm.internal.async.BadVersionException: std::exception in /Users/cm/Realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp line 152
        at io.realm.internal.OsResults.nativeSize(Native Method)
        at io.realm.internal.OsResults.size(OsResults.java:371)
        at io.realm.OrderedRealmCollectionImpl.size(OrderedRealmCollectionImpl.java:341)
        at io.realm.RealmResults.size(RealmResults.java:68)

@cmelchior
Copy link
Contributor

@alexneo2003 Is it something you can reproduce?

@alexneo2003
Copy link

alexneo2003 commented Nov 4, 2019

@cmelchior i'm running Espresso test on my corporate app.
at first starting app in background downloading many static data. like schedule of working time, news by company and etc. and all this data writing in realm database.
at first run in test i'm cleaning app data and run it. and it run background operations with downloading/writing data.
at end of first testing app stoped and runing new test with run new app activity. and app create new instances for downloading/writing data.
but background data after first running still in progress and at this place my app is crashed with same error

in the code, the application checks if the results are not empty then process it with the next step

final RealmResults documents = realm
		.where(StatusDocuments.class)
		.equalTo("isArchive", false)
		.greaterThan("deliveryDate", 0)
		.lessThanOrEqualTo("deliveryDate", archiveDate)
		.findAll();

if (!documents.isEmpty()) {  <<---- crash at this point
    // do something
}

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests