What changed, and why it matters
This commit removes unnecessary mutexes (simple locking mechanisms) from two internal Bitcoin Core fuzz test files. Fuzz tests are automated testing tools, not part of the live Bitcoin network software. The change is a code cleanup: the developers concluded the locks were not needed because fuzz targets run one at a time within a single process. There is no indication this fixes a security vulnerability or affects real users.
No action required. This is a test-only cleanup commit with no security relevance to production Bitcoin Core users or operators.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch drops a global Mutex and related Clang thread-safety annotations from the g_thread_pool startup helpers in src/test/fuzz/coins_view.cpp and src/test/fuzz/coinscache_sim.cpp. The rationale given in the commit message is that fuzz targets are entered sequentially within a process and parallel fuzzing uses separate processes/forks, each with their own global thread pool, so in-process locking is unnecessary. The change is purely within test/fuzz code and does not alter consensus, networking, wallet, or mempool logic.
Changed components
src/test/fuzz/coins_view.cppsrc/test/fuzz/coinscache_sim.cppInspect captured patch +5 / −9
diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp
index 95baccc7..7e2c7634 100644
--- a/src/test/fuzz/coins_view.cpp
+++ b/src/test/fuzz/coins_view.cpp
@@ -91,11 +91,9 @@ public:
// Reuse a single global thread pool across fuzz iterations. Creating and destroying a pool every
// iteration leaks memory, since iterations can run faster than the OS can tear down the threads.
std::shared_ptr<ThreadPool> g_thread_pool{std::make_shared<ThreadPool>("view_fuzz")};
-Mutex g_thread_pool_mutex;
-void StartPoolIfNeeded() EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
+void StartPoolIfNeeded()
{
- LOCK(g_thread_pool_mutex);
if (!g_thread_pool->WorkersCount()) g_thread_pool->Start(DEFAULT_PREVOUTFETCH_THREADS);
}
@@ -436,7 +434,7 @@ FUZZ_TARGET(coins_view_db, .init = initialize_coins_view)
// This allows us to exercise all methods on a CoinsViewOverlay, while also
// ensuring that nothing can mutate the underlying cache until Flush or Sync is
// called.
-FUZZ_TARGET(coins_view_overlay, .init = initialize_coins_view) EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
+FUZZ_TARGET(coins_view_overlay, .init = initialize_coins_view)
{
SeedRandomStateForTest(SeedRand::ZEROS); // for SaltedTxidHasher
StartPoolIfNeeded();
@@ -448,7 +446,7 @@ FUZZ_TARGET(coins_view_overlay, .init = initialize_coins_view) EXCLUSIVE_LOCKS_R
TestCoinsView(fuzzed_data_provider, coins_view_cache, &backend_cache);
}
-FUZZ_TARGET(coins_view_stacked, .init = initialize_coins_view) EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
+FUZZ_TARGET(coins_view_stacked, .init = initialize_coins_view)
{
SeedRandomStateForTest(SeedRand::ZEROS); // for SaltedTxidHasher
StartPoolIfNeeded();
diff --git a/src/test/fuzz/coinscache_sim.cpp b/src/test/fuzz/coinscache_sim.cpp
index 2f4c73e2..3e5d29a2 100644
--- a/src/test/fuzz/coinscache_sim.cpp
+++ b/src/test/fuzz/coinscache_sim.cpp
@@ -207,17 +207,15 @@ struct OverlayFetchScope
// Reuse a single global thread pool across fuzz iterations. Creating and destroying a pool every
// iteration leaks memory, since iterations can run faster than the OS can tear down the threads.
std::shared_ptr<ThreadPool> g_thread_pool{std::make_shared<ThreadPool>("cache_fuzz")};
-Mutex g_thread_pool_mutex;
-void StartPoolIfNeeded() EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
+void StartPoolIfNeeded()
{
- LOCK(g_thread_pool_mutex);
if (!g_thread_pool->WorkersCount()) g_thread_pool->Start(DEFAULT_PREVOUTFETCH_THREADS);
}
} // namespace
-FUZZ_TARGET(coinscache_sim, .init = [] { static auto setup{MakeNoLogFileContext<>()}; }) EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
+FUZZ_TARGET(coinscache_sim, .init = [] { static auto setup{MakeNoLogFileContext<>()}; })
{
SeedRandomStateForTest(SeedRand::ZEROS);
StartPoolIfNeeded();
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.