HomePhabricator

validation: Guard all chainstates with cs_main

Description

validation: Guard all chainstates with cs_main

Summary:
PR description:

This avoids a potential race-condition where a thread is reading the
ChainstateManager::m_active_chainstate pointer while another one is
writing to it. There is no portable guarantee that reading/writing the
pointer is thread-safe.

This is a backport of core#21025

Test Plan:
With debug and tsan:
ninja check check-functional

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
Carl Dong <contact@carldong.me>Authored on Jan 27 2021, 21:20
PiRKCommitted on Jul 21 2022, 07:39
PiRKPushed on Jul 21 2022, 07:39
Reviewer
Restricted Project
Differential Revision
D11773: validation: Guard all chainstates with cs_main
Parents
rABC602209d248fc: validation: remove redundant check on pindex
Branches
Unknown
Tags
Unknown