Skip to content

Commit fa4fb6a

Browse files
author
MarcoFalke
committed
fuzz: Use serial task runner to increase fuzz stability
1 parent 698f869 commit fa4fb6a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/test/util/setup_common.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <util/rbf.h>
5050
#include <util/strencodings.h>
5151
#include <util/string.h>
52+
#include <util/task_runner.h>
5253
#include <util/thread.h>
5354
#include <util/threadnames.h>
5455
#include <util/time.h>
@@ -220,12 +221,15 @@ ChainTestingSetup::ChainTestingSetup(const ChainType chainType, TestOpts opts)
220221
{
221222
const CChainParams& chainparams = Params();
222223

223-
// We have to run a scheduler thread to prevent ActivateBestChain
224+
// A task runner is required to prevent ActivateBestChain
224225
// from blocking due to queue overrun.
225226
if (opts.setup_validation_interface) {
226227
m_node.scheduler = std::make_unique<CScheduler>();
227228
m_node.scheduler->m_service_thread = std::thread(util::TraceThread, "scheduler", [&] { m_node.scheduler->serviceQueue(); });
228-
m_node.validation_signals = std::make_unique<ValidationSignals>(std::make_unique<SerialTaskRunner>(*m_node.scheduler));
229+
m_node.validation_signals =
230+
// Use synchronous task runner while fuzzing to avoid non-determinism
231+
G_FUZZING ? std::make_unique<ValidationSignals>(std::make_unique<util::ImmediateTaskRunner>()) :
232+
std::make_unique<ValidationSignals>(std::make_unique<SerialTaskRunner>(*m_node.scheduler));
229233
}
230234

231235
bilingual_str error{};

0 commit comments

Comments
 (0)