-
Notifications
You must be signed in to change notification settings - Fork 36.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Improve thread safety analysis by propagating some negative capabilities #25175
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -472,15 +472,16 @@ class PeerManagerImpl final : public PeerManager | |||
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex); | |||
void BlockChecked(const CBlock& block, const BlockValidationState& state) override | |||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An annotation is not for a caller, rather for Clang Thread Safety Analysis C++ extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(An external caller (accessing via the virtual/override) can't see the mutex, but an in-class caller could)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was just thinking that it would be incredibly unlikely or even wrong to even have an in-class caller.
Concept ACK |
ACK 2b3373c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 2b3373c
This PR is a follow-up for #22778 and #24062, and it seems required for #24931.
See details in the commit messages.