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

Fix a race between canceling async transaction and Realm.Dispose #3400

Merged
merged 2 commits into from
Jul 28, 2023

Conversation

nirinchev
Copy link
Member

@nirinchev nirinchev commented Jul 26, 2023

Description

Saw that in a CI run: https://github.com/realm/realm-dotnet/actions/runs/5671307649/job/15368851506

Also adds a missing ex.ThrowIfNecessary() in RefreshAsync.

The rest of the changes are primarily cosmetic addressing some local member shadowing which was irritating me and the IDE.

TODO

  • Changelog entry

Sorry, something went wrong.

// return false and we must ignore the cancel request (and let Core proceed with the transaction). This is because
// if we canceled the transaction here, the caller would free the tcs GCHandle while at the same time an async transaction
// would be ongoing which will eventually attempt to use the tcs through the GCHandle, resulting in a hard crash on Mono.
if (!IsClosed &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix for issue 1.

@@ -748,6 +748,8 @@ public async Task<bool> RefreshAsync()
try
{
var didRegister = NativeMethods.refresh_async(this, GCHandle.ToIntPtr(tcsHandle), out var ex);
ex.ThrowIfNecessary();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix for issue 2.

@nirinchev nirinchev requested a review from papafe July 26, 2023 17:43
@nirinchev nirinchev merged commit 1549578 into main Jul 28, 2023
@nirinchev nirinchev deleted the ni/async-commit-handle branch July 28, 2023 00:09
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants