mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
Merge bitcoin/bitcoin#36046: fuzz: Use ImmediateBackgroundTaskRunner in process_messages
fae6665f01fuzz: Use ImmediateBackgroundTaskRunner in process_messages (MarcoFalke) Pull request description: The `process_messages` target may complain about false-positive debug lock-order issues: ``` echo 'Gv8uXPBdXV0QEP//dHVhxyoVKP////8A/0BrLmNrAEEAIP+MXHR0OQAAAAD+///txgIUADBgAAEC fgAAAK0ArQEAAAD/AFwAQf9cdHf5XGhlYWRlcltbyzHIw8RcX2Jsb2NrAAAAAGNtcAAAADAftOvd D0sFqXEx6US5VIknlsOJqZ5goMwtmwZBPdCxQZbatBsWPOR3FcUvSLLsKwcgKT8XdmjvDgskH5pK iAUI/uVJTf//fyAAAAAAAQIAAAAAAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP// //8DAskA/v///wIA+QKVAAAAAAFRAAAAAAAAAAAmaiSqIant4vYcP3HR3v0/qZnfo2lTdVxcaQaJ eZlitIvr2DaXToz5ASAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgAAAD/XPB0eAD/ AgAAAAD9ABZqCwAAAAAEAAAAXPBhYVtbW1tbW1tbW1tbW1tbW1tbW1tbW1tbW1tbW1tbW1tbW1tb W1tb//9bW1tbW1tbW1sAAAAxNgAAADc5MzU5NDk2ODEwNzg3NAAAAAICAgL9a4jAhyQCAgICAQAA AAAABSpvdGhlcir/8wICAgICAAAAeAL0AAAAAAAAaW52O///BAAAAAAAtbW1tWFbW2FhtbVhYWFh YSkpW1tbW2QAJwAAAAAAAAAAMTYAAAA3OTM1OTQ5NjgxMDc4NzQAAAACAgIC/WuIwIckAgICAgEA AAAAAAUAAAAAAv7///MAeAL0AAAAAAAAaW52Ow==' | base64 --decode > /tmp/fuzz.input FUZZ=process_messages ./bld-cmake/bin/fuzz /tmp/fuzz.input --printtoconsole=1 | grep -A99 'POTENTIAL DEADLOCK DETECTED' ``` ``` [test] [sync.cpp:108] [potential_deadlock_detected] [error] POTENTIAL DEADLOCK DETECTED [test] [sync.cpp:109] [potential_deadlock_detected] [error] Previous lock order was: [test] [sync.cpp:118] [potential_deadlock_detected] [error] 'NetEventsInterface::g_msgproc_mutex' in test/fuzz/process_messages.cpp:89 (in thread 'test') [test] [sync.cpp:118] [potential_deadlock_detected] [error] 'm_chainstate_mutex' in validation.cpp:3351 (in thread 'test') [test] [sync.cpp:118] [potential_deadlock_detected] [error] 'cs_main' in validation.cpp:3373 (in thread 'test') [test] [sync.cpp:118] [potential_deadlock_detected] [error] (2) 'MempoolMutex()' in validation.cpp:3376 (in thread 'test') [test] [sync.cpp:118] [potential_deadlock_detected] [error] (1) 'm_tx_download_mutex' in net_processing.cpp:2216 (in thread 'test') [test] [sync.cpp:122] [potential_deadlock_detected] [error] Current lock order is: [test] [sync.cpp:133] [potential_deadlock_detected] [error] 'NetEventsInterface::g_msgproc_mutex' in test/fuzz/process_messages.cpp:89 (in thread 'test') [test] [sync.cpp:133] [potential_deadlock_detected] [error] 'cs_main' in net_processing.cpp:4725 (in thread 'test') [test] [sync.cpp:133] [potential_deadlock_detected] [error] (1) 'm_tx_download_mutex' in net_processing.cpp:4725 (in thread 'test') [test] [sync.cpp:133] [potential_deadlock_detected] [error] (2) 'cs' in txmempool.h:521 (in thread 'test') ``` Fix this by using the `ImmediateBackgroundTaskRunner` from `src/test/fuzz/cmpctblock.cpp`. ACKs for top commit: Crypt-iQ: ACKfae6665f01sedited: ACKfae6665f01marcofleon: tACKfae6665f01frankomosh: Tested ACKfae6665f01Tree-SHA512: 9cee43aa72495abfd69211004b27ee6857d3a1a6bbab9fdc5a8b5349159a54e270236f198a516a7d9087917af8c95ee626e8307155ded8d08314a6b606dd0c33
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
#include <txmempool.h>
|
||||
#include <uint256.h>
|
||||
#include <util/check.h>
|
||||
#include <util/task_runner.h>
|
||||
#include <util/time.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
@@ -48,7 +47,6 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -104,15 +102,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! Used to run tasks in a std::thread to avoid DEBUG_LOCKORDER false positives.
|
||||
class ImmediateBackgroundTaskRunner : public util::TaskRunnerInterface
|
||||
{
|
||||
public:
|
||||
void insert(std::function<void()> func) override { std::thread(std::move(func)).join(); }
|
||||
void flush() override {}
|
||||
size_t size() override { return 0; }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
extern void MakeRandDeterministicDANGEROUS(const uint256& seed) noexcept;
|
||||
|
||||
@@ -50,6 +50,8 @@ void initialize_process_messages()
|
||||
{}),
|
||||
};
|
||||
g_setup = testing_setup.get();
|
||||
// Replace validation_signals before creating chainman and mempool so they use it.
|
||||
g_setup->m_node.validation_signals = std::make_unique<ValidationSignals>(std::make_unique<ImmediateBackgroundTaskRunner>());
|
||||
ResetChainmanAndMempool(*g_setup, init_clock);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
|
||||
#include <consensus/amount.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <util/task_runner.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -19,6 +23,15 @@ class CValidationInterface;
|
||||
class FakeNodeClock;
|
||||
struct TestingSetup;
|
||||
|
||||
/// Runs callbacks synchronously and deterministically, while avoiding DEBUG_LOCKORDER false positives.
|
||||
class ImmediateBackgroundTaskRunner : public util::TaskRunnerInterface
|
||||
{
|
||||
public:
|
||||
void insert(std::function<void()> func) override { std::thread(std::move(func)).join(); }
|
||||
void flush() override {}
|
||||
size_t size() override { return 0; }
|
||||
};
|
||||
|
||||
struct TestBlockManager : public node::BlockManager {
|
||||
/** Test-only method to clear internal state for fuzzing */
|
||||
void CleanupForFuzzing();
|
||||
|
||||
Reference in New Issue
Block a user