Page MenuHomePhabricator

validation: Guard the active_chainstate with cs_main
ClosedPublic

Authored by PiRK on Mar 15 2022, 14:54.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC9ef337192ee9: validation: Guard the active_chainstate with cs_main
Summary

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 also done in way that mimics ::ChainstateActive(), so the
transition from that function to this method is easy.

This is a backport of core#20749 [1/17]
https://github.com/bitcoin/bitcoin/pull/20749/commits/f92dc6557a153b390a1ae1d0808ff7ed5d02c66e

Depends on D11171

Test Plan

With debug:
ninja all check-all