HomePhabricator

Require CBlockIndex::GetBlockPos() to hold mutex cs_main

Description

Require CBlockIndex::GetBlockPos() to hold mutex cs_main

Summary:

consensus: don't call GetBlockPos in ReadBlockFromDisk without lock

The cs_main lock only covered the first invocation of CBlockIndex::GetBlockPos().

Use the blockPos local variable instead of calling the function twice, rename it to block_pos, and make it const

This is a backport of core#22895


Require CBlockIndex::GetBlockPos() to hold mutex cs_main

This is a partial backport of core#22932
https://github.com/bitcoin/bitcoin/pull/22932/commits/6fd4341c10b319399c58d71c4ddeae4417e337d7

Test Plan:
With clang and DEBUG:

ninja all check-all bitcoin-fuzzers

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D13031

Details

Provenance
Jon Atack <jon@atack.com>Authored on Sep 5 2021, 09:32
PiRKCommitted on Jan 24 2023, 09:20
PiRKPushed on Jan 24 2023, 09:21
Reviewer
Restricted Project
Differential Revision
D13031: Require CBlockIndex::GetBlockPos() to hold mutex cs_main
Parents
rABC6cb63834d3ad: Bump version to 0.26.11
Branches
Unknown
Tags
Unknown