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 condition in RWVar #433

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix a race condition in RWVar #433

wants to merge 2 commits into from

Conversation

jorisdral
Copy link
Collaborator

@jorisdral jorisdral commented Oct 14, 2024

retry is interruptible, which can leave the RWVar in a state that is unrecoverable.

Kudos to @jasagredo for finding this subtle bug!

@jorisdral jorisdral force-pushed the jdral/rwvar-racy branch 2 times, most recently from b9e1b11 to 6dd1060 Compare October 15, 2024 08:47
@jorisdral jorisdral self-assigned this Oct 15, 2024
@jorisdral jorisdral marked this pull request as ready for review October 23, 2024 09:47
@jorisdral
Copy link
Collaborator Author

jorisdral commented Oct 23, 2024

This is now ready for review. My takeaway is that from now on I should put more thought into interruptibility when writing exception safe code 😝

`prop_noRace` is updated to properly test interleavings of threads, and threads
can now be cancelled asynchronously. This unearths a subtle race condition in
`unsafeAcquireWriteAccess`, which contains interruptible operations that leave
the internal state of `RWVar` in an unrecoverable state if they happen in just
the right place.
This mainly involves rolling back previous `RWState` changes if an interrupt
happens. The code is extended with comments to explain how the code is now
interrupt-safe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants