-
Notifications
You must be signed in to change notification settings - Fork 359
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
Data race on m_OwnerId for reentrant_spin_lock? #123
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi guys,
We came across the reentrant_spin_lock data structure and seemed to find a potential data race. We may have missed something but just want to report it anyway.
So in the try_lock() or lock() method, they call the try_taken_lock() method, which calls the is_taken() method to check whether the current is holding the lock already. However, it doesn't seem to read the m_OwnerId variable with synchronization/happens-before, and the m_OwnerId variable is not marked as atomic variable. So while a thread is calling try_lock() which reads m_OwnerId, another thread can concurrently writes m_OwnerId, which seems like data race.
So should m_OwnerId be declared as atomic variable according to C++11?
The text was updated successfully, but these errors were encountered: