From 9759af17ff7c28eb909cb73f62b78c90851ab74d Mon Sep 17 00:00:00 2001 From: TheCharlatan Date: Tue, 24 Oct 2023 08:37:12 +0200 Subject: [PATCH 1/2] shutdown: Destroy kernel last Currently the shutdown function resets the kernel before the chainman and scheduler. Invert this order by resetting the kernel last, since they might rely on the kernel. --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index c11f100139d..365e0e83b59 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -341,11 +341,11 @@ void Shutdown(NodeContext& node) node.chain_clients.clear(); UnregisterAllValidationInterfaces(); GetMainSignals().UnregisterBackgroundSignalScheduler(); - node.kernel.reset(); node.mempool.reset(); node.fee_estimator.reset(); node.chainman.reset(); node.scheduler.reset(); + node.kernel.reset(); try { if (!fs::remove(GetPidFile(*node.args))) { From c1144f0076339c775f41d4b5fcfdc72191440d96 Mon Sep 17 00:00:00 2001 From: TheCharlatan Date: Tue, 24 Oct 2023 08:38:06 +0200 Subject: [PATCH 2/2] tests: Reset node context members on ~BasicTestingSetup The destruction/resetting of node context members in the tests should roughly follow the behaviour of the Shutdown function in `init.cpp`. --- src/test/util/setup_common.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 65c657da96b..9ebf0b9561f 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -144,6 +144,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vecto BasicTestingSetup::~BasicTestingSetup() { + m_node.kernel.reset(); SetMockTime(0s); // Reset mocktime for following tests LogInstance().DisconnectTestLogger(); fs::remove_all(m_path_root); @@ -202,8 +203,9 @@ ChainTestingSetup::~ChainTestingSetup() m_node.netgroupman.reset(); m_node.args = nullptr; m_node.mempool.reset(); - m_node.scheduler.reset(); + m_node.fee_estimator.reset(); m_node.chainman.reset(); + m_node.scheduler.reset(); } void ChainTestingSetup::LoadVerifyActivateChainstate()