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

Fixing race condition in condition_variable #2360

Merged
merged 1 commit into from Oct 13, 2016
Merged

Fixing race condition in condition_variable #2360

merged 1 commit into from Oct 13, 2016

Conversation

sithhell
Copy link
Member

@sithhell sithhell commented Oct 9, 2016

We need to reaquire the lock in lcos::detail::condition_variable::wait(_until)
in order to avoid a race condition between setting the thread id to invalid
and resetting the queue entry

Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

Looks like this indeed is a problem. The oversight is that the destructor of reset_queue_entry requires for the mutex to be re-acquired. Nice catch!

We need to reaquire the lock in lcos::detail::condition_variable::wait(_until)
in order to avoid a race condition between setting the thread id to invalid
and resetting the queue entry
@sithhell
Copy link
Member Author

The previous changes haven't been 100% correct. I amended the commit with additional changes. Please review again.

Copy link
Contributor

@biddisco biddisco left a comment

Choose a reason for hiding this comment

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

I can't see anything wrong in this

Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

LGTM!

@sithhell sithhell merged commit 20180e3 into master Oct 13, 2016
@sithhell sithhell deleted the cv_race_fix branch October 13, 2016 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants