HomePhabricator

[backport#16849] Fix block index inconsistency in InvalidateBlock()

Description

[backport#16849] Fix block index inconsistency in InvalidateBlock()

Summary:
Fix block index inconsistency in InvalidateBlock() (Suhas Daftuar)

Pull request description:

Previously, we could release `cs_main` while leaving the block index in a state
that would fail `CheckBlockIndex()`, because `setBlockIndexCandidates` was not being
fully populated before releasing `cs_main`.

Note: Because of the way our version of "InvalidateBlock" is in the codepath for Park, Invalidate and FinalizeBlock, the lock for m_cs_chainstate needs to appear in additional places.

Backport of Core PR16849

Depends on D6956

Test Plan:

cmake -DCMAKE_BUILD_TYPE=Debug -DNinja
ninja check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

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

Details

Provenance
Wladimir J. van der Laan <laanwj@protonmail.com>Authored on Oct 2 2019, 11:39
majcostaCommitted on Aug 18 2020, 13:26
majcostaPushed on Aug 18 2020, 13:26
Reviewer
Restricted Project
Differential Revision
D7204: [backport#16849] Fix block index inconsistency in InvalidateBlock()
Parents
rABC5d825d4abb76: [thread safety] prevent double lock of cs_main in calls to CChainState…
Branches
Unknown
Tags
Unknown