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

Unpredictable crash: Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first. #8675

Open
aehlke opened this issue Sep 4, 2024 · 6 comments

Comments

@aehlke
Copy link

aehlke commented Sep 4, 2024

How frequently does the bug occur?

Sometimes

Description

I get this crash inconsistently, and across many different areas of my codebase seemingly randomly

image

Here is the view of the stack trace showing that it happens from inside asyncWrite

image

And here is a snippet of the code showing the error happening inside the asyncWrite (but this crash happens across a variety of asyncWrite calls). The object being mutated belongs to the realm that the asyncWrite happens on. Usually the calls where it crashes work, too.

I have all writes per realm file happening on their own actors (at most one actor per realm file for writes, so that all writes happen in one actor for each realm)

It happens maybe once every 20-30 runs while developing. I've removed all references to realm.refresh / realm.asyncRefresh. Are there any other potential causes for this that I can check my codebase for?

Stacktrace & log output

No response

Can you reproduce the bug?

Sometimes

Reproduction Steps

No response

Version

10.53.0

What Atlas Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

macOS 14.6.1

Build environment

Xcode version: Xcode 16 beta 6
Dependency manager and version: SPM

@aehlke aehlke added the T-Bug label Sep 4, 2024
@aehlke aehlke changed the title Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first. Unpredictable crash: Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first. Sep 4, 2024
Copy link

sync-by-unito bot commented Sep 4, 2024

➤ PM Bot commented:

Jira ticket: RCOCOA-2425

@aehlke
Copy link
Author

aehlke commented Sep 4, 2024

try this select the desired compiler in the installer

I have no way to report this comment for abuse - it has a malware link! I reported the profile.

@aehlke
Copy link
Author

aehlke commented Sep 4, 2024

Sorry, in this case I may have a programming error where the object doesn't belong to that Realm. But I've seen this in other cases too recently. I will update.

@emirvajzovic
Copy link

Hi, I am experiencing the similar issue when my app randomly crashes even though code is wrapped in .write { }.
Can you provide more details for your case? It could be helpful for me as well.

@aehlke
Copy link
Author

aehlke commented Oct 17, 2024

@emirvajzovic make sure all writes for a realm happen in same actor
also if you await on something it's possible that objects you had fetched before become invalidated by the time you write to them, that might also be an issue if I recall
Realm is also dead now so let's move to something else...

@emirvajzovic
Copy link

@aehlke thanks for the reply. I had a weird issue with multiple realm instances and I was trying to write in the wrong one. I'd like to move to something else but unfortunately it's a project that I'm only maintaining and there is no budget for any improvements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@aehlke @emirvajzovic and others