Fixes #15980.
Hold cs_main when reading chainActive (via ::ChainActive()) in RewindBlockIndex.
Fixes #15980.
Hold cs_main when reading chainActive (via ::ChainActive()) in RewindBlockIndex.
utACK https://github.com/bitcoin/bitcoin/pull/16015/commits/7232a23949e7dc934f2b1d6dce888f4f51c1ce93
Is there going to be a wider effort to find all instances of unguarded chainActive use?
@jamesob Yes, I'll work on that :-)
Why are you using WITH_LOCK? FlushStateToDisk requires cs_main anyway, so might as well take the lock for the reminder of the function?
@MarcoFalke OK, no harm in holding cs_main for the remainder of the function: updated accordingly. Please re-review :-)
Why not add the annotation in ::ChainActive()?
Why not add the annotation in ::ChainActive()?
I think because as noted earlier, there're various existing violations of that that need to be fixed first.
@promag The end goal is ::ChainActive() EXCLUSIVE_LOCKS_REQUIRED(cs_main), but there are a few violations that must be addressed first.
So why this change in particularly? Are those violations more than adding the lock? If so then those should be submitted first IMO.
utACK anyway.
@promag This is in validation code so it needs extra care in reviewing. I'll take the non-critical cases separately.
The other cases are also validation related, IIRC
@MarcoFalke It's a mixed bag IIRC. Do I have your utACK on this one?
utACK 1609809fb2a4c2ec15b7c26dc328e2e666bd5d57