Data race condition in ‘boost/thread/lock_types.hpp’
- Dominant language
- C++
- Stars
- 214
- Forks
- 171
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I've just run Coverity, version 2020.03, static analysis on a program using Boost v 1_75_0
It has highlighted several potential issues one of which I will describe here.
In lock_types.hpp the ‘unique_lock’ class contains a mutex and a Boolean guard, called ‘is_locked’, is checked, via the ‘owns_lock()’ method, prior to locking and unlocking the mutex and then set to true or false respectively. For example, on line 451 the mutex is unlocked and on line 452 the ‘is_locked’ is set to false. Another thread can at the same time call owns_lock() to check the locked status and potentially get wrong answer.
This, to me and the Coverity static analysis, creates a data race condition. Is that a false positive in the static analysis tool? What am I missing?
Thanks,
Dimitar
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.