You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AssumeUTXO snapshot completion during startup can start an index thread twice #37079
If importing historical blocks finishes background validation before the normal startup index step, the snapshot-completion callback starts each index thread first. Startup then calls StartBackgroundSync() again, assigns over the still-joinable thread, and aborts.
Reproducer
This calls StartBackgroundSync() twice directly, as the two startup paths do.
diff --git a/src/test/baseindex_tests.cpp b/src/test/baseindex_tests.cpp
index 28ed5f8614..c49c0c4555 100644
--- a/src/test/baseindex_tests.cpp+++ b/src/test/baseindex_tests.cpp@@ -2,6 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <bitcoin-build-config.h>+
#include <addresstype.h>
#include <blockfilter.h>
#include <chain.h>
@@ -39,6 +41,12 @@
#include <memory>
#include <string>
#include <thread>
++#if HAVE_DECL_FORK+#include <csignal>+#include <sys/wait.h>+#include <unistd.h>+#endif
#include <utility>
#include <vector>
@@ -235,4 +243,24 @@ BOOST_FIXTURE_TEST_CASE(index_reorg_crash, TestChain100Setup)
StopIndex(index, m_node);
}
+#if HAVE_DECL_FORK+BOOST_FIXTURE_TEST_CASE(baseindex_double_start_aborts, TestChain100Setup)+{+ const pid_t pid{fork()};+ BOOST_REQUIRE(pid >= 0);+ if (pid == 0) {+ std::signal(SIGABRT, SIG_DFL);+ TxIndex index{interfaces::MakeChain(m_node), /*n_cache_size=*/1_MiB, /*f_memory=*/true};+ if (!index.Init() || !index.StartBackgroundSync()) _exit(1);+ if (!index.StartBackgroundSync()) _exit(2);+ _exit(3);+ }++ int status{0};+ BOOST_REQUIRE_EQUAL(waitpid(pid, &status, 0), pid);+ BOOST_CHECK(WIFSIGNALED(status));+ BOOST_CHECK_EQUAL(WTERMSIG(status), SIGABRT); // TODO: Starting an index twice must not abort+}+#endif+
BOOST_AUTO_TEST_SUITE_END()
The direct fix would be to let only one of the two paths start each index thread, but given that AssumeUTXO fixes haven't attracted much review, I'm proposing to remove AssumeUTXO entirely in #36598 instead.
Activity