refactor: Improve thread safety analysis by propagating some negative capabilities#25175
Merged
maflcko merged 2 commits intobitcoin:masterfrom May 20, 2022
Merged
refactor: Improve thread safety analysis by propagating some negative capabilities#25175maflcko merged 2 commits intobitcoin:masterfrom
maflcko merged 2 commits intobitcoin:masterfrom
Conversation
Could be verified with $ ./configure CC=clang CXX=clang++ CXXFLAGS='-Wthread-safety -Wthread-safety-negative' $ make clean $ make 2>&1 | grep m_most_recent_block_mutex
Could be verified with $ ./configure CC=clang CXX=clang++ CXXFLAGS='-Wthread-safety -Wthread-safety-negative' $ make clean $ make 2>&1 | grep m_tx_relay_mutex
maflcko
approved these changes
May 20, 2022
| EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex); | ||
| void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override; | ||
| void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override | ||
| EXCLUSIVE_LOCKS_REQUIRED(!m_most_recent_block_mutex); |
Member
There was a problem hiding this comment.
I wonder how useful it is to annotate interface functions with member mutexes. The only allowed caller can't see the mutex, as it is private.
Member
Author
There was a problem hiding this comment.
An annotation is not for a caller, rather for Clang Thread Safety Analysis C++ extension.
Contributor
There was a problem hiding this comment.
(An external caller (accessing via the virtual/override) can't see the mutex, but an in-class caller could)
Member
There was a problem hiding this comment.
Yeah, I was just thinking that it would be incredibly unlikely or even wrong to even have an in-class caller.
Member
|
Concept ACK |
Contributor
|
ACK 2b3373c |
w0xlt
approved these changes
May 20, 2022
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR is a follow-up for #22778 and #24062, and it seems required for #24931.
See details in the commit messages.