-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #951: [Consensus] Protect mapBlockIndex with its own mutex
13dd025 chain: Set all CBlockIndex members to null, remove SetNull helper (MarcoFalke) ad442a4 Give mapBlockIndex its own lock. (Zannick) Pull request description: ### Problem tsan identified a data race on CChainState, particularly between AcceptBlock and ActivateBestChain (used often by the miner threads). ### Solution Mark `mapBlockIndex` as guarded by `cs_mapblockindex`, and ensure that the lock is taken prior to any use. Some code has been reorganized slightly to reduce the time spent holding the lock and avoid locking a second time for the same information. Move many lookups to use LookupBlockIndex, which grabs the lock itself, and remove lots of cs_main uses that would have otherwise blocked only for LookupBlockIndex. ### Tested Original: Configured with --with-sanitizers=tsan, built with clang, run on regtest with 2 SHA mining threads enabled. With cs_mapblockindex: configured --with-sanitizers=tsan, built with clang, run on testnet to catch up and mine 2 sha threads. Tree-SHA512: 3a972c964fa365bd455bcd28a3f62d1d28e023bd17c47dbd42d2349549d95940b08271bb214bc1a1cea811fc106c57543e20e96297e84dbd0490de0c1dece0ec
- Loading branch information
Showing
21 changed files
with
409 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.