-
Notifications
You must be signed in to change notification settings - Fork 172
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
Crash when Realm is querying objects in a process while another process is committing transactions #7111
Comments
This is not a supported scenario, and crashes are expected behavior. From the docs for the
Read-only mode is there to let you read Realm files bundled with your app and not much else. |
Oof 😳 I've been using Realm for the last 8ish years and this is the first time I've heard this, read only mode was the only way to use an encrypted Realm in an extension. Is there an alternative? I see that multiprocess encryption has finally been added, I'll also give that a try. |
@tgoyne apparently this is still a valid issue. Using Realm in read-write mode reduces the likelihood of the crash happening, but doesn't prevent it altogether. I have updated the test project at https://github.com/alinradut/realm-has_refs-crash and it is reproducible 100%. I no longer encountered
The exception seems to be eventually thrown in
and the error message is coming from
No precise idea about what the code does, but a naive impression would be that it's checking whether someone else is connected to the database and it doesn't see the main app that's also working on it (maybe because it caught it in between writes), so it assumes its dealing with an incorrect key and throws the error. The key cannot be wrong as it's fixed and 64 Maybe a few more retries wouldn't be amiss here? |
@tgoyne: can this issue be reopened or should I file a new one? 🤔 |
@alinradut thanks for the reporting this and for the reproducer! I've checked the code you've provided and it looks similar to what we already test in our test/test_lang_bind_helper.cpp tests. So, essentially you keep adding batch of objects in every transaction to the realm in a loop in one process, and query for the count of added objects in the other process, right? Could you confirm a few thing:
Looking at the assertion and its values it should happen only here on the first retry - and according to the code no concurrent write was detected. What does it tell us, @finnschiermer? |
@kiburtse exactly, that's exactly what I am trying to do, write some batched data in a process while another process tries to pull data from the Realm db (not necessarily connected to the data that is being written). This fails both on the simulator and on a real device. I've only noticed this crash in the reader process, I can't say I've seen other errors. |
@kiburtse are you able to reproduce? |
Just bumping this issue after re-testing it with the latest release, it's still reproducible and present in RealmSwift 10.50.0. |
Same issue and this is open from 2023 !! |
➤ jedelbo commented: [~[email protected]] would you be able to check if this is reproducible? Apparently there is a reproduction test case. |
Original reporter here. I just tried the test project with the latest realm-swift (10.54.0) and the crash is still very much happening. |
@tgoyne ^ |
SDK and version
SDK : RealmSwift
Version: 10.44.0
Observations
Reproducible almost always.
Both
Yes
Yes, a test project is available at https://github.com/alinradut/realm-has_refs-crash
Crash log / stacktrace
Steps & Code to Reproduce
A test project is available at https://github.com/alinradut/realm-has_refs-crash
You need to start the main app, click "Run test", then share something using the sharing extension where you'll tap "Run test" as well.
The sharing extension will soon crash. The fastest way to reproduce it would be to tap "Run test" twice in the sharing extension.
The reason of the crash can vary, most of my users get
Assertion failed: has_refs()
, but this test usually brings out theabort() called
crash, although I believe they are connected.I've also created an issue a few weeks ago on realm-swift, but I figured I should create it here as well for visibility.
The text was updated successfully, but these errors were encountered: