-
Notifications
You must be signed in to change notification settings - Fork 38.7k
wallet: Add compile time checking for cs_wallet runtime locking assertions #13081
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
wallet: Add compile time checking for cs_wallet runtime locking assertions #13081
Conversation
|
utACK c51b9e36e98ed1fd2151d923ae233970c4c39713 |
|
Looks like GetConflicts was missed, |
c51b9e3 to
775b74e
Compare
|
@TheBlueMatt Correct! Added! @MarcoFalke @TheBlueMatt Please re-review! :-) |
src/wallet/wallet.cpp
Outdated
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.
Add this to the header file instead?
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.
Moving it to the header file would generate a member access into an at that stage incomplete type CWallet I'm afraid. Any suggestion?
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.
You can solve it by moving stuff around in the header file (i.e. make a forward declaration of CWalletTx, move the CWalletTx to the line after CWallet, move methods that still depend on the type to the cpp file, then add all the locking annotations. Note that just adding the annotation here is not sufficient, since I get a warning in wallet/rpcwallet.cpp...)
Personally, I had the feeling that c51b9e3 was a clear and obvious step in the right direction. I don't like to hold back the pull request based on that a single method was "missed". That can be fixed up later in a separate pull ... I'd suggest resetting hard to c51b9e3 and merge it
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.
@practicalswift @TheBlueMatt Any further thoughts here?
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.
@MarcoFalke Good point. I'll revert to c51b9e3.
dea4474 to
c51b9e3
Compare
|
Now reverted to c51b9e36e98ed1fd2151d923ae233970c4c39713 as suggested by @MarcoFalke. Will add Ready for merge? :-) |
|
@ryanofsky or @jnewbery You are doing a lot with the wallet lately. Mind taking a look here? |
c51b9e3 to
1b34bda
Compare
|
re-utACK 1b34bda4c9beb993e2378a5c8cb22f92c421eba0 |
ryanofsky
left a comment
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.
@ryanofsky or @jnewbery You are doing a lot with the wallet lately. Mind taking a look here?
utACK 1b34bda4c9beb993e2378a5c8cb22f92c421eba0.
I'm not very familiar with these annotations, but spot checking a few of them, they looked correct, and I assume there is basically no harm if an annotation is added incorrectly (other than maybe having to remove the annotation in a future change?). I also didn't check for missing annotations, because that seemed equally harmless.
|
Needs rebase |
1b34bda to
66b0b1b
Compare
|
Rebased! Please re-review :-) |
|
re-utACK 66b0b1b |
… locking assertions 66b0b1b Add compile time checking for all cs_wallet runtime locking assertions (practicalswift) Pull request description: Add compile time checking for `cs_wallet` runtime locking assertions. This PR is a subset of #12665. The PR was broken up to make reviewing easier. The intention is that literally all `EXCLUSIVE_LOCKS_REQUIRED`/`LOCKS_EXCLUDED`:s added in this PR should follow either directly or indirectly from `AssertLockHeld(…)`/`AssertLockNotHeld(…)`:s already existing in the repo. Consider the case where function `A(…)` contains `AssertLockHeld(cs_foo)` (without first locking `cs_foo` in `A`), and that `B(…)` calls `A(…)` (without first locking `cs_main`): * It _directly_ follows that: `A(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. * It _indirectly_ follows that: `B(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. Tree-SHA512: d561d89e98a823922107e56dbd493f0f82e22edac91e51e6422f17daf2b446a70c143b7b157ca618fadd33d0ec63eb7a57dde5a83bfdf1fc19d71459b43e21fd
… locking assertions Summary: 66b0b1b Add compile time checking for all cs_wallet runtime locking assertions (practicalswift) Pull request description: Add compile time checking for `cs_wallet` runtime locking assertions. This PR is a subset of #12665. The PR was broken up to make reviewing easier. The intention is that literally all `EXCLUSIVE_LOCKS_REQUIRED`/`LOCKS_EXCLUDED`:s added in this PR should follow either directly or indirectly from `AssertLockHeld(…)`/`AssertLockNotHeld(…)`:s already existing in the repo. Consider the case where function `A(…)` contains `AssertLockHeld(cs_foo)` (without first locking `cs_foo` in `A`), and that `B(…)` calls `A(…)` (without first locking `cs_main`): * It _directly_ follows that: `A(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. * It _indirectly_ follows that: `B(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. Tree-SHA512: d561d89e98a823922107e56dbd493f0f82e22edac91e51e6422f17daf2b446a70c143b7b157ca618fadd33d0ec63eb7a57dde5a83bfdf1fc19d71459b43e21fd Backport of Core PR13081 bitcoin/bitcoin#13081 Depends on D3998 Test Plan: ./configure CXX=clang++ CC=clang make check Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3981
… locking assertions Summary: 66b0b1b2a6 Add compile time checking for all cs_wallet runtime locking assertions (practicalswift) Pull request description: Add compile time checking for `cs_wallet` runtime locking assertions. This PR is a subset of #12665. The PR was broken up to make reviewing easier. The intention is that literally all `EXCLUSIVE_LOCKS_REQUIRED`/`LOCKS_EXCLUDED`:s added in this PR should follow either directly or indirectly from `AssertLockHeld(…)`/`AssertLockNotHeld(…)`:s already existing in the repo. Consider the case where function `A(…)` contains `AssertLockHeld(cs_foo)` (without first locking `cs_foo` in `A`), and that `B(…)` calls `A(…)` (without first locking `cs_main`): * It _directly_ follows that: `A(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. * It _indirectly_ follows that: `B(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. Tree-SHA512: d561d89e98a823922107e56dbd493f0f82e22edac91e51e6422f17daf2b446a70c143b7b157ca618fadd33d0ec63eb7a57dde5a83bfdf1fc19d71459b43e21fd Backport of Core PR13081 bitcoin/bitcoin#13081 Depends on D3998 Test Plan: ./configure CXX=clang++ CC=clang make check Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3981
… locking assertions Summary: 66b0b1b2a6 Add compile time checking for all cs_wallet runtime locking assertions (practicalswift) Pull request description: Add compile time checking for `cs_wallet` runtime locking assertions. This PR is a subset of #12665. The PR was broken up to make reviewing easier. The intention is that literally all `EXCLUSIVE_LOCKS_REQUIRED`/`LOCKS_EXCLUDED`:s added in this PR should follow either directly or indirectly from `AssertLockHeld(…)`/`AssertLockNotHeld(…)`:s already existing in the repo. Consider the case where function `A(…)` contains `AssertLockHeld(cs_foo)` (without first locking `cs_foo` in `A`), and that `B(…)` calls `A(…)` (without first locking `cs_main`): * It _directly_ follows that: `A(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. * It _indirectly_ follows that: `B(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. Tree-SHA512: d561d89e98a823922107e56dbd493f0f82e22edac91e51e6422f17daf2b446a70c143b7b157ca618fadd33d0ec63eb7a57dde5a83bfdf1fc19d71459b43e21fd Backport of Core PR13081 bitcoin/bitcoin#13081 Depends on D3998 Test Plan: ./configure CXX=clang++ CC=clang make check Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3981
…runtime locking assertions 66b0b1b Add compile time checking for all cs_wallet runtime locking assertions (practicalswift) Pull request description: Add compile time checking for `cs_wallet` runtime locking assertions. This PR is a subset of bitcoin#12665. The PR was broken up to make reviewing easier. The intention is that literally all `EXCLUSIVE_LOCKS_REQUIRED`/`LOCKS_EXCLUDED`:s added in this PR should follow either directly or indirectly from `AssertLockHeld(…)`/`AssertLockNotHeld(…)`:s already existing in the repo. Consider the case where function `A(…)` contains `AssertLockHeld(cs_foo)` (without first locking `cs_foo` in `A`), and that `B(…)` calls `A(…)` (without first locking `cs_main`): * It _directly_ follows that: `A(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. * It _indirectly_ follows that: `B(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. Tree-SHA512: d561d89e98a823922107e56dbd493f0f82e22edac91e51e6422f17daf2b446a70c143b7b157ca618fadd33d0ec63eb7a57dde5a83bfdf1fc19d71459b43e21fd
…runtime locking assertions 66b0b1b Add compile time checking for all cs_wallet runtime locking assertions (practicalswift) Pull request description: Add compile time checking for `cs_wallet` runtime locking assertions. This PR is a subset of bitcoin#12665. The PR was broken up to make reviewing easier. The intention is that literally all `EXCLUSIVE_LOCKS_REQUIRED`/`LOCKS_EXCLUDED`:s added in this PR should follow either directly or indirectly from `AssertLockHeld(…)`/`AssertLockNotHeld(…)`:s already existing in the repo. Consider the case where function `A(…)` contains `AssertLockHeld(cs_foo)` (without first locking `cs_foo` in `A`), and that `B(…)` calls `A(…)` (without first locking `cs_main`): * It _directly_ follows that: `A(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. * It _indirectly_ follows that: `B(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation. Tree-SHA512: d561d89e98a823922107e56dbd493f0f82e22edac91e51e6422f17daf2b446a70c143b7b157ca618fadd33d0ec63eb7a57dde5a83bfdf1fc19d71459b43e21fd
Add compile time checking for
cs_walletruntime locking assertions.This PR is a subset of #12665. The PR was broken up to make reviewing easier.
The intention is that literally all
EXCLUSIVE_LOCKS_REQUIRED/LOCKS_EXCLUDED:s added in this PR should follow either directly or indirectly fromAssertLockHeld(…)/AssertLockNotHeld(…):s already existing in the repo.Consider the case where function
A(…)containsAssertLockHeld(cs_foo)(withoutfirst locking
cs_fooinA), and thatB(…)callsA(…)(without first lockingcs_main):A(…)should have anEXCLUSIVE_LOCKS_REQUIRED(cs_foo)annotation.B(…)should have anEXCLUSIVE_LOCKS_REQUIRED(cs_foo)annotation.