Guard CBlockIndex::nStatus/nFile/nDataPos/nUndoPos by cs_main
Summary:
CBlockIndex::nStatus may be racy, i.e. potentially accessed by multiple threads, see core#17161. A solution is to guard it by cs_main, along with fellow data members nFile, nDataPos and nUndoPos.
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
This concludes backport of core#22932 and core#24197
https://github.com/bitcoin/bitcoin/pull/22932/commits/6ea56827842b9b2bd730edc38f3a7b1f46f6247b
https://github.com/bitcoin/bitcoin/pull/24197/commits/20276ca5d124285bdd1bda4cd777ca186b378555
Depends on D13037
Test Plan:
With clang and DEBUG:
ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D13038