From a8573c942f53dcb65808410bd3162ea1a8c335e0 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 20 Nov 2023 19:08:48 +0300 Subject: [PATCH] fix: avoid crashes on "corrupted db" reindex attempts (#5717) ## Issue being fixed or feature implemented Should fix crashes like ``` : Corrupted block database detected. Please restart with -reindex or -reindex-chainstate to recover. Assertion failure: assertion: globalInstance == nullptr file: mnhftx.cpp, line: 43 function: CMNHFManager 0#: (0x105ADA27C) stacktraces.cpp:629 - __assert_rtn 1#: (0x104945794) mnhftx.cpp:43 - CMNHFManager::CMNHFManager(CEvoDB&) 2#: (0x10499DA90) compressed_pair.h:40 - std::__1::__unique_if::__unique_single std::__1::make_unique[abi:v15006](CEvoDB&) 3#: (0x10499753C) init.cpp:1915 - AppInitMain(std::__1::variant, std::__1::reference_wrapper, std::__1::reference_wrapper, std::__1::reference_wrapper, std::__1::reference_wrapper, std::__1::reference_wrapper> const&, NodeContext&, interfaces::BlockAndHeaderTipInfo*) ``` ## What was done? ## How Has This Been Tested? ## Breaking Changes n/a ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ --- src/init.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/init.cpp b/src/init.cpp index 8a5d30fa27..518bb71c76 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1912,6 +1912,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc LOCK(cs_main); node.evodb.reset(); node.evodb = std::make_unique(nEvoDbCache, false, fReset || fReindexChainState); + node.mnhf_manager.reset(); node.mnhf_manager = std::make_unique(*node.evodb); chainman.Reset();