[DRAFT] [racerd] apply the lock releases of callees and destructors to their callers - #2206
Draft
VladimirMakaev wants to merge 1 commit into
Draft
VladimirMakaev wants to merge 1 commit into
VladimirMakaev wants to merge 1 commit into
Conversation
…callers
RacerD counted held locks with a saturating counter and skipped destructors, so unlock helpers and
custom RAII guards never released their caller's lock:
```cpp
struct Guard {
explicit Guard(std::mutex& m) : m_(m) { m_.lock(); }
~Guard() { m_.unlock(); }
std::mutex& m_;
};
void C::set(int v) { std::lock_guard<std::mutex> l(mu_); x_ = v; }
int C::get() {
{ Guard g(mu_); }
return x_; // Infer missed: lock consistency violation
}
```
Track the lock state as its effect on the locks held on entry, `n -> max(0, n - released) + held`,
which composes across calls, and analyse destructors for this effect only. A guard that is not a
local variable, e.g. a member, may release a lock held on entry.
Limitations:
- locks have no identity: a lock held on entry that a callee releases is taken to be the last lock
its caller acquired;
- guard members are assumed to own their lock when destroyed;
- classes that lock only through callees are still not considered concurrent (see facebook#2211).
## Test plan
New `cpp/racerd/unlock_in_callee.cpp`. In `java/racerd`, `FN_releaseLockInCalleeBad` is now
reported and renamed, and `FP_releaseLockOfCallerInCalleeOk` shows the first limitation. The
codetoanalyze tests pass.
VladimirMakaev
force-pushed
the
racerd-callee-unlock
branch
from
October 3, 2026 21:52
f7d044e to
780aacb
Compare
This was referenced Oct 4, 2026
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.
RacerD counted held locks with a saturating counter and skipped destructors, so unlock helpers and
custom RAII guards never released their caller's lock:
Track the lock state as its effect on the locks held on entry,
n -> max(0, n - released) + held,which composes across calls, and analyse destructors for this effect only. A guard that is not a
local variable, e.g. a member, may release a lock held on entry.
Limitations:
its caller acquired;
Test plan
New
cpp/racerd/unlock_in_callee.cpp. Injava/racerd,FN_releaseLockInCalleeBadis nowreported and renamed, and
FP_releaseLockOfCallerInCalleeOkshows the first limitation. Thecodetoanalyze tests pass.