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 [[https://github.com/bitcoin/bitcoin/pull/21025 | core#21025]]