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