-
Notifications
You must be signed in to change notification settings - Fork 37.7k
util: Add Clang thread safety annotations for variables guarded by cs_args #13126
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
Conversation
05d6e62
to
83b6e7c
Compare
Now includes a fix for a missing |
83b6e7c
to
02616c4
Compare
02616c4
to
7f1cc8f
Compare
Rebased! |
The last travis run for this pull request was 53 days ago and is thus outdated. To trigger a fresh travis build, this pull request should be closed and re-opened. |
if (m_override_args.count("-includeconf") == 0) { | ||
bool emptyIncludeConf; | ||
{ | ||
LOCK(cs_args); |
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.
ReadConfigFiles
is done once on start. Couldn't you just take the lock at the beginning of the method and remove those scoped locks further down in the method?
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.
This change caused the deadlock. Now reverted to previous version :-)
src/util.cpp
Outdated
@@ -387,6 +388,7 @@ void ArgsManager::WarnForSectionOnlyArgs() | |||
// if it's okay to use the default section for this network, don't worry | |||
if (m_network == CBaseChainParams::MAIN) return; | |||
|
|||
LOCK(cs_args); |
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.
Just take the lock in the very first line of this method, or is there a specific reason that m_network
shouldn't be protected?
7f1cc8f
to
f4d0f5c
Compare
@MarcoFalke Thanks for reviewing! Feedback addressed. Please re-review :-) |
Added |
src/util.cpp
Outdated
@@ -304,6 +304,7 @@ class ArgsManagerHelper { | |||
static inline bool GetNetBoolArg(const ArgsManager &am, const std::string& net_arg) | |||
{ | |||
std::pair<bool,std::string> found_result(false,std::string()); | |||
LOCK(am.cs_args); |
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'd prefer to annotate this function and then take the lock where GetNetBoolArg
is called (in GetChainName
)
src/util.cpp
Outdated
@@ -886,7 +891,8 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys) | |||
} | |||
// if there is an -includeconf in the override args, but it is empty, that means the user | |||
// passed '-noincludeconf' on the command line, in which case we should not include anything | |||
if (m_override_args.count("-includeconf") == 0) { | |||
bool emptyIncludeConf = m_override_args.count("-includeconf") == 0; | |||
if (emptyIncludeConf) { |
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.
Why this change?
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.
Oh, that was likely a left-over from a previous commit - a separate variable was needed to limit the scope of the lock. When the lock was moved higher up that was no longer needed but the variable was accidentally left around.
utACK, but could squash into two commits (1) add missing locks and (2) add lock annotations |
d0d69b1
to
26add58
Compare
@MarcoFalke Good points. PR adjusted accordingly. Please re-review :-) |
|
@MarcoFalke Thanks! I'll investigate immediately! |
26add58
to
a8fac9f
Compare
Note that I reproduced this with |
@MarcoFalke Strange! I always build with |
No, triggered by |
0b1506a
to
8c747a4
Compare
src/util.cpp
Outdated
m_config_args.clear(); | ||
{ | ||
LOCK(cs_args); | ||
m_config_args.clear(); |
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.
Couldn't you just move those two lines after the GetConfigFile();
call? (And remove all scopes and re-locks?)
b16fb00
to
2d326da
Compare
111354a
to
e492de8
Compare
@MarcoFalke Please re-review :-) |
This still fails travis for the same reason. Sorry, I guess my suggestion doesn't work. |
e492de8
to
1e29379
Compare
@MarcoFalke Reverted again :-) Travis is now happy. Please re-review! |
… guarded by cs_args 1e29379 Fix potential deadlock (practicalswift) d58dc9f Add lock annotations (cs_args) (practicalswift) db5e9d3 Add missing locks (cs_args) (practicalswift) Pull request description: * Add missing `cs_args` locks * Add Clang thread safety annotations for variables guarded by `cs_args` Tree-SHA512: bc562dbddf24a287bcf9bf902bc930f942f260a94e5c8ec4d190f7f2ddac448ed3d52acadaf9fc1c81a5cbff2c171c52c18ba0804eeb03f699d70394e1c977c5
… guarded by cs_args Summary: 1e29379d69 Fix potential deadlock (practicalswift) d58dc9f943 Add lock annotations (cs_args) (practicalswift) db5e9d3c88 Add missing locks (cs_args) (practicalswift) Pull request description: * Add missing `cs_args` locks * Add Clang thread safety annotations for variables guarded by `cs_args` Tree-SHA512: bc562dbddf24a287bcf9bf902bc930f942f260a94e5c8ec4d190f7f2ddac448ed3d52acadaf9fc1c81a5cbff2c171c52c18ba0804eeb03f699d70394e1c977c5 Backport of Core PR13126 bitcoin/bitcoin#13126 Completes T652 Test Plan: cmake -GNinja .. -DENABLE_WERROR=ON ninja check Also run `build-werror` and `build-tsan` builds. Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc, markblundeberg Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Subscribers: markblundeberg Differential Revision: https://reviews.bitcoinabc.org/D4965
… guarded by cs_args Summary: 1e29379d69 Fix potential deadlock (practicalswift) d58dc9f943 Add lock annotations (cs_args) (practicalswift) db5e9d3c88 Add missing locks (cs_args) (practicalswift) Pull request description: * Add missing `cs_args` locks * Add Clang thread safety annotations for variables guarded by `cs_args` Tree-SHA512: bc562dbddf24a287bcf9bf902bc930f942f260a94e5c8ec4d190f7f2ddac448ed3d52acadaf9fc1c81a5cbff2c171c52c18ba0804eeb03f699d70394e1c977c5 Backport of Core PR13126 bitcoin/bitcoin#13126 Completes T652 Test Plan: cmake -GNinja .. -DENABLE_WERROR=ON ninja check Also run `build-werror` and `build-tsan` builds. Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc, markblundeberg Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Subscribers: markblundeberg Differential Revision: https://reviews.bitcoinabc.org/D4965
… guarded by cs_args Summary: 1e29379d69 Fix potential deadlock (practicalswift) d58dc9f943 Add lock annotations (cs_args) (practicalswift) db5e9d3c88 Add missing locks (cs_args) (practicalswift) Pull request description: * Add missing `cs_args` locks * Add Clang thread safety annotations for variables guarded by `cs_args` Tree-SHA512: bc562dbddf24a287bcf9bf902bc930f942f260a94e5c8ec4d190f7f2ddac448ed3d52acadaf9fc1c81a5cbff2c171c52c18ba0804eeb03f699d70394e1c977c5 Backport of Core PR13126 bitcoin/bitcoin#13126 Completes T652 Test Plan: cmake -GNinja .. -DENABLE_WERROR=ON ninja check Also run `build-werror` and `build-tsan` builds. Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc, markblundeberg Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Subscribers: markblundeberg Differential Revision: https://reviews.bitcoinabc.org/D4965
…riables guarded by cs_args 1e29379 Fix potential deadlock (practicalswift) d58dc9f Add lock annotations (cs_args) (practicalswift) db5e9d3 Add missing locks (cs_args) (practicalswift) Pull request description: * Add missing `cs_args` locks * Add Clang thread safety annotations for variables guarded by `cs_args` Tree-SHA512: bc562dbddf24a287bcf9bf902bc930f942f260a94e5c8ec4d190f7f2ddac448ed3d52acadaf9fc1c81a5cbff2c171c52c18ba0804eeb03f699d70394e1c977c5 # Conflicts: # src/util/system.cpp
…riables guarded by cs_args 1e29379 Fix potential deadlock (practicalswift) d58dc9f Add lock annotations (cs_args) (practicalswift) db5e9d3 Add missing locks (cs_args) (practicalswift) Pull request description: * Add missing `cs_args` locks * Add Clang thread safety annotations for variables guarded by `cs_args` Tree-SHA512: bc562dbddf24a287bcf9bf902bc930f942f260a94e5c8ec4d190f7f2ddac448ed3d52acadaf9fc1c81a5cbff2c171c52c18ba0804eeb03f699d70394e1c977c5 # Conflicts: # src/util/system.cpp
…riables guarded by cs_args 1e29379 Fix potential deadlock (practicalswift) d58dc9f Add lock annotations (cs_args) (practicalswift) db5e9d3 Add missing locks (cs_args) (practicalswift) Pull request description: * Add missing `cs_args` locks * Add Clang thread safety annotations for variables guarded by `cs_args` Tree-SHA512: bc562dbddf24a287bcf9bf902bc930f942f260a94e5c8ec4d190f7f2ddac448ed3d52acadaf9fc1c81a5cbff2c171c52c18ba0804eeb03f699d70394e1c977c5 # Conflicts: # src/util/system.cpp
…riables guarded by cs_args 1e29379 Fix potential deadlock (practicalswift) d58dc9f Add lock annotations (cs_args) (practicalswift) db5e9d3 Add missing locks (cs_args) (practicalswift) Pull request description: * Add missing `cs_args` locks * Add Clang thread safety annotations for variables guarded by `cs_args` Tree-SHA512: bc562dbddf24a287bcf9bf902bc930f942f260a94e5c8ec4d190f7f2ddac448ed3d52acadaf9fc1c81a5cbff2c171c52c18ba0804eeb03f699d70394e1c977c5 # Conflicts: # src/util/system.cpp
cs_args
lockscs_args