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

Data race on m_OwnerId for reentrant_spin_lock? #123

Open
peizhaoo opened this issue May 30, 2018 · 1 comment
Open

Data race on m_OwnerId for reentrant_spin_lock? #123

peizhaoo opened this issue May 30, 2018 · 1 comment

Comments

@peizhaoo
Copy link

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?

@khizmax
Copy link
Owner

khizmax commented May 31, 2018

Strictly speaking you are right.

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

No branches or pull requests

2 participants