asan: lock cs_main for calls to chainman

This commit is contained in:
Byron Hambly 2025-01-06 13:58:28 +02:00
parent ffa0c01a17
commit c794f76ea8
No known key found for this signature in database
GPG key ID: DE8F6EA20A661697
4 changed files with 13 additions and 7 deletions

View file

@ -2766,7 +2766,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
// the received headers. We can still get ahead by up to a single maximum-sized
// headers message here, but never further, so that's fine.
if (m_chainman.m_best_header) {
int64_t headers_ahead = m_chainman.m_best_header->nHeight - m_chainman.ActiveHeight();
int64_t headers_ahead = m_chainman.m_best_header->nHeight - WITH_LOCK(::cs_main, return m_chainman.ActiveHeight());
bool too_far_ahead = node::fTrimHeaders && (headers_ahead >= node::nHeaderDownloadBuffer);
if (too_far_ahead) {
LOCK(cs_main);