Merge #16015: validation: Hold cs_main when reading chainActive in RewindBlockIndex

1609809fb2 validation: Hold cs_main when reading chainActive in RewindBlockIndex (practicalswift)

Pull request description:

  Fixes #15980.

  Hold `cs_main` when reading `chainActive` (via `::ChainActive()`) in `RewindBlockIndex`.

ACKs for commit 160980:
  MarcoFalke:
    utACK 1609809fb2

Tree-SHA512: 54f180ab391f92f04950735c2bb337f0b7495826d2096f7a0f9a2da50bc29d08747f404a0495e33ca4edd4c842efbab4c4730d5e1a8b9da3e1249cf884268f4b
This commit is contained in:
MarcoFalke 2019-05-22 08:17:46 -04:00
commit 1c177c3a00
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25

View file

@ -4307,6 +4307,7 @@ bool RewindBlockIndex(const CChainParams& params) {
return false;
}
LOCK(cs_main);
if (::ChainActive().Tip() != nullptr) {
// FlushStateToDisk can possibly read ::ChainActive(). Be conservative
// and skip it here, we're about to -reindex-chainstate anyway, so