Skip to content

Commit c4216e8

Browse files
committed
Merge bitcoin/bitcoin#35723: fuzz: Drop unnecessary mutexes
240d5f7 fuzz: Drop unnecessary mutexes (marcofleon) Pull request description: Quick cleanup addressing bitcoin/bitcoin#35295 (comment). This follows the same logic as 48df093 from bitcoin/bitcoin#35521. ACKs for top commit: maflcko: lgtm ACK 240d5f7 nervana21: ACK 240d5f7 l0rinc: code review ACK 240d5f7 Tree-SHA512: 869127dc8cec4fc0688f92d67dc22f643cf3741c62d645eb4a959a9d8f46590efe19765f7df97ee36f9a3ca759c50fe983a3e6655e40a53ea99904e7a1ec00f6
2 parents cf0368f + 240d5f7 commit c4216e8

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/test/fuzz/coins_view.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,9 @@ class MutationGuardCoinsViewCache final : public CCoinsViewCache
9191
// Reuse a single global thread pool across fuzz iterations. Creating and destroying a pool every
9292
// iteration leaks memory, since iterations can run faster than the OS can tear down the threads.
9393
std::shared_ptr<ThreadPool> g_thread_pool{std::make_shared<ThreadPool>("view_fuzz")};
94-
Mutex g_thread_pool_mutex;
9594

96-
void StartPoolIfNeeded() EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
95+
void StartPoolIfNeeded()
9796
{
98-
LOCK(g_thread_pool_mutex);
9997
if (!g_thread_pool->WorkersCount()) g_thread_pool->Start(DEFAULT_PREVOUTFETCH_THREADS);
10098
}
10199

@@ -436,7 +434,7 @@ FUZZ_TARGET(coins_view_db, .init = initialize_coins_view)
436434
// This allows us to exercise all methods on a CoinsViewOverlay, while also
437435
// ensuring that nothing can mutate the underlying cache until Flush or Sync is
438436
// called.
439-
FUZZ_TARGET(coins_view_overlay, .init = initialize_coins_view) EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
437+
FUZZ_TARGET(coins_view_overlay, .init = initialize_coins_view)
440438
{
441439
SeedRandomStateForTest(SeedRand::ZEROS); // for SaltedTxidHasher
442440
StartPoolIfNeeded();
@@ -448,7 +446,7 @@ FUZZ_TARGET(coins_view_overlay, .init = initialize_coins_view) EXCLUSIVE_LOCKS_R
448446
TestCoinsView(fuzzed_data_provider, coins_view_cache, &backend_cache);
449447
}
450448

451-
FUZZ_TARGET(coins_view_stacked, .init = initialize_coins_view) EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
449+
FUZZ_TARGET(coins_view_stacked, .init = initialize_coins_view)
452450
{
453451
SeedRandomStateForTest(SeedRand::ZEROS); // for SaltedTxidHasher
454452
StartPoolIfNeeded();

src/test/fuzz/coinscache_sim.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,15 @@ struct OverlayFetchScope
207207
// Reuse a single global thread pool across fuzz iterations. Creating and destroying a pool every
208208
// iteration leaks memory, since iterations can run faster than the OS can tear down the threads.
209209
std::shared_ptr<ThreadPool> g_thread_pool{std::make_shared<ThreadPool>("cache_fuzz")};
210-
Mutex g_thread_pool_mutex;
211210

212-
void StartPoolIfNeeded() EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
211+
void StartPoolIfNeeded()
213212
{
214-
LOCK(g_thread_pool_mutex);
215213
if (!g_thread_pool->WorkersCount()) g_thread_pool->Start(DEFAULT_PREVOUTFETCH_THREADS);
216214
}
217215

218216
} // namespace
219217

220-
FUZZ_TARGET(coinscache_sim, .init = [] { static auto setup{MakeNoLogFileContext<>()}; }) EXCLUSIVE_LOCKS_REQUIRED(!g_thread_pool_mutex)
218+
FUZZ_TARGET(coinscache_sim, .init = [] { static auto setup{MakeNoLogFileContext<>()}; })
221219
{
222220
SeedRandomStateForTest(SeedRand::ZEROS);
223221
StartPoolIfNeeded();

0 commit comments

Comments
 (0)