-
Notifications
You must be signed in to change notification settings - Fork 38.7k
mempool: Add compile time checking for ::mempool.cs runtime locking assertions #13080
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
src/rpc/blockchain.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.
All the locks are taken. I don't see why this is necessary.
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 invalidateblock(…) calls InvalidateBlock(…) without first locking ::mempool.cs. Calling InvalidateBlock(…) requires holding mutex mempool.cs exclusively. Then it follows that calling invalidateblock(…) should require ::mempool.cs too which is what the annotation says? What am I missing? :-)
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.
Calling InvalidateBlock(…) requires holding mutex mempool.cs
Yeah, I looked and it seems all the locks are taken here, which one did I miss?
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.
Ah, sorry. The InvalidateBlock(…) annotation seems incorrect. Thanks!
65379d3 to
04ce4b6
Compare
|
@MarcoFalke Updated! Please re-review :-) |
04ce4b6 to
03774ef
Compare
|
utACK 03774eff0e6f5242f02125cecb4d61fa74c00300 |
src/rpc/blockchain.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.
How'd this slip in here? I'm kinda surprised it even linked with this.
03774ef to
aa8341e
Compare
|
@TheBlueMatt Thanks! Updated. Please re-review :-) |
|
re-utACK aa8341e3ae934587149dd609b542b21f9cf6017f (Only change was to get rid of unrelated change) |
|
Missing CheckSequenceLocks. |
|
@TheBlueMatt Given that @MarcoFalke has utACK:ed aa8341e and in light of #13081 (comment), what about adding Both |
|
re-utACK cbba1d2 |
…time locking assertions cbba1d2 Add compile time checking for all ::mempool.cs runtime locking assertions (practicalswift) Pull request description: Add compile time checking for `::mempool.cs` 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: 1b5ec1cfca6be67edd1298fea1a52b5572ce833dd4ad05c4583f753c2d3229402663373675df87e950151d5c41aeb3ee02f0ad935ed83fe2f45ca8e4d55d901e
….cs runtime locking assertions cbba1d2 Add compile time checking for all ::mempool.cs runtime locking assertions (practicalswift) Pull request description: Add compile time checking for `::mempool.cs` 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: 1b5ec1cfca6be67edd1298fea1a52b5572ce833dd4ad05c4583f753c2d3229402663373675df87e950151d5c41aeb3ee02f0ad935ed83fe2f45ca8e4d55d901e
….cs runtime locking assertions cbba1d2 Add compile time checking for all ::mempool.cs runtime locking assertions (practicalswift) Pull request description: Add compile time checking for `::mempool.cs` 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: 1b5ec1cfca6be67edd1298fea1a52b5572ce833dd4ad05c4583f753c2d3229402663373675df87e950151d5c41aeb3ee02f0ad935ed83fe2f45ca8e4d55d901e
Add compile time checking for
::mempool.csruntime 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.