From faf9c8e8a12cff5ef4f277d8c3f1035776e57c14 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 2 Sep 2026 12:57:49 +0200 Subject: [PATCH 1/3] test: Clarify index.GetSummary().synced state in index_reorg_crash This clarifies the initial index sync thread is blocked. --- src/test/baseindex_tests.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/baseindex_tests.cpp b/src/test/baseindex_tests.cpp index 4e9a03a1856..68907ad28d8 100644 --- a/src/test/baseindex_tests.cpp +++ b/src/test/baseindex_tests.cpp @@ -223,6 +223,9 @@ BOOST_FIXTURE_TEST_CASE(index_reorg_crash, TestChain100Setup) BOOST_REQUIRE(m_node.chainman->ProcessNewBlock(block, /*force_processing=*/true, /*min_pow_checked=*/true, nullptr)); } + // The index thread is blocked and not done + BOOST_CHECK(!index.GetSummary().synced); + // Unblock the index thread so it can process the reorg promise.set_value(); // Wait for the index to reach the new tip From fa0f14ef5e76424ed7770936f7d053f27336a601 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 2 Sep 2026 13:22:08 +0200 Subject: [PATCH 2/3] test: Avoid unsafe memory race in index_reorg_crash shutdown Without the drain, a BlockConnected event may execute during shutdown and lead to memory races. --- src/test/baseindex_tests.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/baseindex_tests.cpp b/src/test/baseindex_tests.cpp index 68907ad28d8..63f3c912f2a 100644 --- a/src/test/baseindex_tests.cpp +++ b/src/test/baseindex_tests.cpp @@ -230,6 +230,10 @@ BOOST_FIXTURE_TEST_CASE(index_reorg_crash, TestChain100Setup) promise.set_value(); // Wait for the index to reach the new tip func_wait_until(blocking_height + 2, 5s); + + // Drain unused BlockConnected events, to avoid unsafe memory races during destruction + m_node.chain->context()->validation_signals->SyncWithValidationInterfaceQueue(); + // shutdown sequence (c.f. Shutdown() in init.cpp) index.Stop(); } From fab80e82c1087126477e07eda5f6e3a1f25ceb99 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 2 Sep 2026 16:47:51 +0200 Subject: [PATCH 3/3] test: Avoid unsafe memory race in baseindex_no_commit_ahead_of_flush Without the drain, a BlockConnected event may execute during shutdown and lead to memory races. --- src/test/baseindex_tests.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/baseindex_tests.cpp b/src/test/baseindex_tests.cpp index 63f3c912f2a..1d8ae17cbcd 100644 --- a/src/test/baseindex_tests.cpp +++ b/src/test/baseindex_tests.cpp @@ -84,6 +84,10 @@ BOOST_FIXTURE_TEST_CASE(baseindex_no_commit_ahead_of_flush, TestChain100Setup) // Reload index to see which block data was actually committed. BOOST_REQUIRE(index->Init()); BOOST_CHECK_EQUAL(index->GetSummary().best_block_height, expected_commit_height); + + // Drain in-flight validation callbacks before destroying the index. + m_node.chain->context()->validation_signals->SyncWithValidationInterfaceQueue(); + // shutdown sequence (c.f. Shutdown() in init.cpp) index->Stop(); };