-
Notifications
You must be signed in to change notification settings - Fork 164
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
RCORE-2004 Make Realm::call_completion_callbacks() resilient to trasaction being deleted #7437
Conversation
Pull Request Test Coverage Report for Build jorgen.edelbo_175Details
💛 - Coveralls |
The sequence of events that'd hit this is that the async write completes, schedules the call to run_async_completions(), and then close() or invalidate() is called before the scheduler gets to run. It seems like it should be possible to test this (maybe with a custom Scheduler implementation that closes the Realm when the completion handler is scheduled?). It might be better to change the early return to |
@tgoyne I had the same idea as you, but realized that calling close() or invalidate() already flushes the callback-queue (through do_invalidate()). |
Calling do_invalidate() from call_completion_callback() will lead to recursion. |
I didn't say anything about calling do_invalidate() from call_completion_callback()? |
Ok, but then I did not understand your suggestion. I just think that as long as we don't fully understand what leads up to this exception, then it is better to just fix the symptom. |
@tgoyne I am not sure what the next step here should be. |
It could use a test. |
@tgoyne So could I. The problem is that I can't create a test that reproduces this (as explained before). Can you see other ways that |
This can be reproduced with a custom scheduler that lets us invoke the callback at the correct time:
|
@tgoyne Thank you very much for your help here. My mind was kind of trapped. I can now see that I misread your suggestion for a fix. I totally agree that that is the right solution. |
What, How & Why?
Fixes #7434
I was not able to reproduce the problem, so mayby we are not getting the full picture. But this change will at lease prevent a nullpointer exception if the transaction is terminated.
☑️ ToDos
bindgen/spec.yml
, if public C++ API changed