From fab80e82c1087126477e07eda5f6e3a1f25ceb99 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 2 Sep 2026 16:47:51 +0200 Subject: [PATCH] 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(); };