Repository navigation
[racerd][starvation] pair accesses and locks whose root types differ only in qualifiers - #2167
Open
VladimirMakaev wants to merge 1 commit into
Open
VladimirMakaev wants to merge 1 commit into
VladimirMakaev wants to merge 1 commit into
Conversation
VladimirMakaev
force-pushed
the
concurrency-const-this
branch
from
October 3, 2026 20:12
a026f87 to
023807b
Compare
VladimirMakaev
force-pushed
the
concurrency-const-this
branch
from
October 5, 2026 06:53
023807b to
8ecc034
Compare
VladimirMakaev
added a commit
to VladimirMakaev/infer
that referenced
this pull request
Oct 5, 2026
…only in qualifiers The clang frontend types `this` as `C const *` in the const methods of `C` and as `C *` elsewhere. RacerD and Starvation compared these types with their qualifiers when pairing accesses or locks of two methods, missing races and deadlocks involving const methods: Expectation conflicts with earlier frontier commits were resolved automatically in: infer/tests/codetoanalyze/cpp/racerd/issues.exp Upstream-PR: meta#2167 PR-Head: 8ecc034 PR-Base: 9cc2641
VladimirMakaev
force-pushed
the
concurrency-const-this
branch
from
October 7, 2026 15:55
8ecc034 to
b56ace7
Compare
Contributor
Author
|
Will reopen once current PR queue is cleared |
…only in qualifiers
The clang frontend types `this` as `C const *` in the const methods of `C` and as `C *` elsewhere.
RacerD and Starvation compared these types with their qualifiers when pairing accesses or locks of
two methods, missing races and deadlocks involving const methods:
```cpp
#include <mutex>
class C {
std::mutex m_;
int x_;
public:
int get() const { return x_; } // Infer missed: LOCK_CONSISTENCY_VIOLATION
void set(int v) {
std::lock_guard<std::mutex> l(m_);
x_ = v;
}
};
```
RacerD now ignores the base type when grouping accesses, as `AccessPath.compare` does. Starvation
compares the root types of parameter-rooted locks across threads modulo qualifiers, so `const C *`
parameters also pair with `C *` ones.
Trade-off: two-instance deadlocks with const on one side only, such as `x.copy_from(&y)` against
`y.copy_to(&x)`, are no longer reported, like the same code without const.
## Test plan
New tests `cpp/racerd/const_methods.cpp` and `cpp/starvation/const_methods.cpp`. Of their `_bad`
cases, main reports only the two-instance deadlock `FN_copy_from_bad`, which is no longer
reported. All codetoanalyze tests pass.
VladimirMakaev
force-pushed
the
concurrency-const-this
branch
from
November 5, 2026 14:56
b56ace7 to
1ecd7c3
Compare
VladimirMakaev
marked this pull request as ready for review
November 5, 2026 14:56
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The clang frontend types
thisasC const *in the const methods ofCand asC *elsewhere.RacerD and Starvation compared these types with their qualifiers when pairing accesses or locks of
two methods, missing races and deadlocks involving const methods:
RacerD now ignores the base type when grouping accesses, as
AccessPath.comparedoes. Starvationcompares the root types of parameter-rooted locks across threads modulo qualifiers, so
const C *parameters also pair with
C *ones.Trade-off: two-instance deadlocks with const on one side only, such as
x.copy_from(&y)againsty.copy_to(&x), are no longer reported, like the same code without const.Test plan
New tests
cpp/racerd/const_methods.cppandcpp/starvation/const_methods.cpp. Of their_badcases, main reports only the two-instance deadlock
FN_copy_from_bad, which is no longerreported. All codetoanalyze tests pass.