-
Notifications
You must be signed in to change notification settings - Fork 38.7k
mempool: Fix missing locking in CTxMemPool::check(…) and CTxMemPool::setSanityCheck(…) #11689
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
|
ACK 2abe610. Unrelated, but should read |
|
@promag Yes, I'll ping in @MarcoFalke and @TheBlueMatt for a comment. What do you say? :-) |
|
Actually |
|
Technically there is no issue here - mempool (should only be) modified with cs_main and mempool.check is only called with cs_main. Indeed, probably just move the lock to the top of the function. Unless you want to go to the trouble of making nCheckFrequency a const, best to fix it for the static analysis just like the rest. |
2abe610 to
fd13497
Compare
|
@TheBlueMatt @promag Thanks for reviewing! An updated version has now been pushed taking into account the formal locking requirements of |
|
Added a commit with the Clang thread safety analysis annotations to facilitate reviewing. @promag, would you mind re-reviewing? :-) |
24ce4cf to
0431003
Compare
|
Updated with annotations moved over to the header files. The |
|
As mentioned before, please do not place EXCLUSIVE_LOCKS_REQUIRED annotations on class member function declarations instead of their definitions. Placing them on declarations makes the annotations incredibly brittle and, thus, largely useless. Better to leave them off than to add them in a place where the order of functions in a file matters. |
93bde20 to
661db1d
Compare
|
@TheBlueMatt Sorry, I had missed moving the annotations for |
|
utACK 661db1d63afcea4016ccb7f97fda6cde7f719826 |
661db1d to
36441af
Compare
|
Rebased! |
36441af to
682778d
Compare
* reading variable 'mapTx' requires holding mutex 'cs' * reading variable 'mapNextTx' requires holding mutex 'cs' * reading variable 'nCheckFrequency' requires holding mutex 'cs'
* writing variable 'nCheckFrequency' requires holding mutex 'cs'
682778d to
47782b4
Compare
|
@promag @sipa Would you mind re-reviewing? @MarcoFalke Would you mind reviewing? :-) |
|
utACK 47782b4 |
…d CTxMemPool::setSanityCheck(…) 47782b4 Add Clang thread safety analysis annotations (practicalswift) 0e2dfa8 Fix missing locking in CTxMemPool::setSanityCheck(double dFrequency) (practicalswift) 6bc5b71 Fix missing locking in CTxMemPool::check(const CCoinsViewCache *pcoins) (practicalswift) Pull request description: Fix missing locking in `CTxMemPool::check(const CCoinsViewCache *pcoins)`: * reading variable `mapTx` requires holding mutex `cs` * reading variable `mapNextTx` requires holding mutex `cs` * reading variable `nCheckFrequency` requires holding mutex `cs` Fix missing locking in `CTxMemPool::setSanityCheck(double dFrequency)`: * writing variable `nCheckFrequency` requires holding mutex `cs` Tree-SHA512: ce7c365ac89225223fb06e6f469451b121acaa499f35b21ad8a6d2a266c91194639b3703c5428871be033d4f5f7be790cc297bd8c25b2e0c59345ef09c3693d0
…k(…) and CTxMemPool::setSanityCheck(…) 47782b4 Add Clang thread safety analysis annotations (practicalswift) 0e2dfa8 Fix missing locking in CTxMemPool::setSanityCheck(double dFrequency) (practicalswift) 6bc5b71 Fix missing locking in CTxMemPool::check(const CCoinsViewCache *pcoins) (practicalswift) Pull request description: Fix missing locking in `CTxMemPool::check(const CCoinsViewCache *pcoins)`: * reading variable `mapTx` requires holding mutex `cs` * reading variable `mapNextTx` requires holding mutex `cs` * reading variable `nCheckFrequency` requires holding mutex `cs` Fix missing locking in `CTxMemPool::setSanityCheck(double dFrequency)`: * writing variable `nCheckFrequency` requires holding mutex `cs` Tree-SHA512: ce7c365ac89225223fb06e6f469451b121acaa499f35b21ad8a6d2a266c91194639b3703c5428871be033d4f5f7be790cc297bd8c25b2e0c59345ef09c3693d0
* reading variable 'mapTx' requires holding mutex 'cs' * reading variable 'mapNextTx' requires holding mutex 'cs' * reading variable 'nCheckFrequency' requires holding mutex 'cs' zcash: cherry picked from commit 6bc5b71 zcash: bitcoin/bitcoin#11689
* writing variable 'nCheckFrequency' requires holding mutex 'cs' zcash: cherry picked from commit 0e2dfa8 zcash: bitcoin/bitcoin#11689
zcash: cherry picked from commit 47782b4 zcash: bitcoin/bitcoin#11689
* reading variable 'mapTx' requires holding mutex 'cs' * reading variable 'mapNextTx' requires holding mutex 'cs' * reading variable 'nCheckFrequency' requires holding mutex 'cs' zcash: cherry picked from commit 6bc5b71 zcash: bitcoin/bitcoin#11689
* writing variable 'nCheckFrequency' requires holding mutex 'cs' zcash: cherry picked from commit 0e2dfa8 zcash: bitcoin/bitcoin#11689
zcash: cherry picked from commit 47782b4 zcash: bitcoin/bitcoin#11689
…k(…) and CTxMemPool::setSanityCheck(…) 47782b4 Add Clang thread safety analysis annotations (practicalswift) 0e2dfa8 Fix missing locking in CTxMemPool::setSanityCheck(double dFrequency) (practicalswift) 6bc5b71 Fix missing locking in CTxMemPool::check(const CCoinsViewCache *pcoins) (practicalswift) Pull request description: Fix missing locking in `CTxMemPool::check(const CCoinsViewCache *pcoins)`: * reading variable `mapTx` requires holding mutex `cs` * reading variable `mapNextTx` requires holding mutex `cs` * reading variable `nCheckFrequency` requires holding mutex `cs` Fix missing locking in `CTxMemPool::setSanityCheck(double dFrequency)`: * writing variable `nCheckFrequency` requires holding mutex `cs` Tree-SHA512: ce7c365ac89225223fb06e6f469451b121acaa499f35b21ad8a6d2a266c91194639b3703c5428871be033d4f5f7be790cc297bd8c25b2e0c59345ef09c3693d0
Fix missing locking in
CTxMemPool::check(const CCoinsViewCache *pcoins):mapTxrequires holding mutexcsmapNextTxrequires holding mutexcsnCheckFrequencyrequires holding mutexcsFix missing locking in
CTxMemPool::setSanityCheck(double dFrequency):nCheckFrequencyrequires holding mutexcs