Fix Weak Increment Race Condition#60
Merged
Merged
Conversation
notgull
requested changes
May 23, 2023
notgull
left a comment
Contributor
There was a problem hiding this comment.
Bump the MSRV to 1.45, since fetch_update wasn't stable until then.
Also run cargo fmt --all to keep the code looking nice.
Contributor
Author
|
@notgull CI is passing now, except the MSRV check is failing, seemingly due a flaky failure to download the Cargo registry. Could you please rerun that action? I don't have permission |
notgull
reviewed
May 29, 2023
notgull
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me aside from a minor ordering change.
| } else { | ||
| Some(Sender { | ||
| match self.channel.sender_count.fetch_update( | ||
| Ordering::Relaxed, |
Contributor
There was a problem hiding this comment.
The set ordering here should be Release.
Contributor
Author
There was a problem hiding this comment.
Could you elaborate on what this would guard against? I'm not seeing any other writes that this would need to be ordered with, but I'm probably just missing something
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The sender/receiver counts are currently read and updated separately, which means there's a possible race condition where two attempt to get upgraded from different threads at the same time. This PR switches to using
fetch_updateto avoid this issue