Data race condition in ‘boost/thread/lock_types.hpp’
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- operating-systems
Research direction
Start with boost/thread/lock_types.hpp, focusing on unique_lock, owns_lock(), and the line 451-452 unlock and is_locked update described in the report. Reproduce or inspect the Coverity 2020.03 finding and determine whether concurrent status checks can race with locking or unlocking. Done means establishing whether this is a false positive and documenting or resolving the issue with maintainer agreement.
Written by the indexing model from the issue text.
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
- Dominant language
- C++
- Stars
- 213
- Forks
- 171
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/thread
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
Similar issues
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 88/100
QuantStack/git2cpp#187 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100