From e9f3aa5f6a7b39e8d5f2069617e5e382798d8d60 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 19 Jan 2022 14:03:37 +0100 Subject: Require CBlockIndex::RaiseValidity() to hold cs_main --- src/chain.h | 3 ++- src/test/fuzz/chain.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/chain.h b/src/chain.h index 2eb780d499..c2a9cba1e6 100644 --- a/src/chain.h +++ b/src/chain.h @@ -328,8 +328,9 @@ public: //! Raise the validity level of this block index entry. //! Returns true if the validity was changed. - bool RaiseValidity(enum BlockStatus nUpTo) + bool RaiseValidity(enum BlockStatus nUpTo) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { + AssertLockHeld(::cs_main); assert(!(nUpTo & ~BLOCK_VALID_MASK)); // Only validity flags allowed. if (nStatus & BLOCK_FAILED_MASK) return false; diff --git a/src/test/fuzz/chain.cpp b/src/test/fuzz/chain.cpp index 4f97e1ebb1..8c0ed32d51 100644 --- a/src/test/fuzz/chain.cpp +++ b/src/test/fuzz/chain.cpp @@ -58,7 +58,7 @@ FUZZ_TARGET(chain) if (block_status & ~BLOCK_VALID_MASK) { continue; } - (void)disk_block_index->RaiseValidity(block_status); + WITH_LOCK(::cs_main, (void)disk_block_index->RaiseValidity(block_status)); } CBlockIndex block_index{block_header}; -- cgit v1.2.3