Skip to content

Conversation

@practicalswift
Copy link
Contributor

@practicalswift practicalswift commented Apr 25, 2018

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.

@maflcko
Copy link
Member

maflcko commented Apr 26, 2018

utACK c51b9e36e98ed1fd2151d923ae233970c4c39713

@TheBlueMatt
Copy link
Contributor

Looks like GetConflicts was missed,

@practicalswift practicalswift force-pushed the cs_wallet-compile-time-checking branch from c51b9e3 to 775b74e Compare April 29, 2018 20:04
@practicalswift
Copy link
Contributor Author

@TheBlueMatt Correct! Added!

@MarcoFalke @TheBlueMatt Please re-review! :-)

Copy link
Member

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?

Copy link
Contributor Author

@practicalswift practicalswift Apr 30, 2018

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?

Copy link
Member

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

Copy link
Member

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?

Copy link
Contributor Author

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.

@practicalswift practicalswift changed the title Add compile time checking for all cs_wallet runtime locking assertions wallet: Add compile time checking for all cs_wallet runtime locking assertions Apr 30, 2018
@practicalswift practicalswift force-pushed the cs_wallet-compile-time-checking branch 2 times, most recently from dea4474 to c51b9e3 Compare May 2, 2018 18:51
@practicalswift
Copy link
Contributor Author

Now reverted to c51b9e36e98ed1fd2151d923ae233970c4c39713 as suggested by @MarcoFalke. Will add GetConflicts(…) in a later PR.

Ready for merge? :-)

@maflcko
Copy link
Member

maflcko commented May 2, 2018

@ryanofsky or @jnewbery You are doing a lot with the wallet lately. Mind taking a look here?

@practicalswift practicalswift changed the title wallet: Add compile time checking for all cs_wallet runtime locking assertions wallet: Add compile time checking for cs_wallet runtime locking assertions May 3, 2018
@practicalswift practicalswift force-pushed the cs_wallet-compile-time-checking branch from c51b9e3 to 1b34bda Compare May 5, 2018 06:10
@maflcko
Copy link
Member

maflcko commented May 5, 2018

re-utACK 1b34bda4c9beb993e2378a5c8cb22f92c421eba0

Copy link
Contributor

@ryanofsky ryanofsky left a 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.

@maflcko
Copy link
Member

maflcko commented May 14, 2018

Needs rebase

@practicalswift practicalswift force-pushed the cs_wallet-compile-time-checking branch from 1b34bda to 66b0b1b Compare May 14, 2018 12:57
@practicalswift
Copy link
Contributor Author

Rebased! Please re-review :-)

@maflcko
Copy link
Member

maflcko commented May 14, 2018

re-utACK 66b0b1b

@maflcko maflcko merged commit 66b0b1b into bitcoin:master May 14, 2018
maflcko pushed a commit that referenced this pull request May 14, 2018
… 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
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 13, 2019
… 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
jonspock pushed a commit to jonspock/devault that referenced this pull request Dec 22, 2019
… 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
proteanx pushed a commit to devaultcrypto/devault that referenced this pull request Dec 23, 2019
… 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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2020
…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
@practicalswift practicalswift deleted the cs_wallet-compile-time-checking branch April 10, 2021 19:34
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 10, 2022
…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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants