From 23812555b181746503d8bde2f1ec0b0fe3a9926f Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 22 Aug 2024 01:39:06 +0700 Subject: [PATCH] fix: possible deadlock during calculation of signals for historical blocks during re-index Relevant crash dump: Assertion failed: detected inconsistent lock order for 'cs_main' in node/blockstorage.cpp:778 (in thread 'main'), details in debug log. Posix Signal: Aborted 0#: (0x62349D233974) stl_vector.h:115 - std::_Vector_base >::_Vector_impl_data::_M_copy_data(std::_Vector_base >::_Vector_impl_data const&) 1#: (0x62349D233974) stl_vector.h:127 - std::_Vector_base >::_Vector_impl_data::_M_swap_data(std::_Vector_base >::_Vector_impl_data&) 2#: (0x62349D233974) stl_vector.h:1959 - std::vector >::_M_move_assign(std::vector >&&, std::integral_constant) 3#: (0x62349D233974) stl_vector.h:768 - std::vector >::operator=(std::vector >&&) 4#: (0x62349D233974) stacktraces.cpp:777 - HandlePosixSignal 5#: (0x71E435442990) libc_sigaction.c - ??? 6#: (0x71E435499A1B) pthread_kill.c:44 - __pthread_kill_implementation 7#: (0x71E435499A1B) pthread_kill.c:78 - __pthread_kill_internal 8#: (0x71E435499A1B) pthread_kill.c:89 - __GI___pthread_kill 9#: (0x71E4354428E6) raise.c:27 - __GI_raise 10#: (0x71E4354268B7) abort.c:81 - __GI_abort 11#: (0x62349D239956) basic_string.h:390 - std::__cxx11::basic_string, std::allocator >::_M_check_length(unsigned long, unsigned long, char const*) const 12#: (0x62349D239956) basic_string.h:1461 - std::__cxx11::basic_string, std::allocator >::append(char const*) 13#: (0x62349D239956) basic_string.h:1365 - std::__cxx11::basic_string, std::allocator >::operator+=(char const*) 14#: (0x62349D239956) sync.cpp:114 - potential_deadlock_detected 15#: (0x62349D2403DE) sync.cpp:188 - push_lock 16#: (0x62349D2403DE) sync.cpp:212 - void EnterCritical(char const*, char const*, int, std::recursive_mutex*, bool) 17#: (0x62349CAA8B72) unique_lock.h:150 - std::unique_lock::try_lock() 18#: (0x62349CAA8B72) sync.h:162 - UniqueLock, std::unique_lock >::Enter(char const*, char const*, int) 19#: (0x62349CAA8B72) sync.h:183 - UniqueLock, std::unique_lock >::UniqueLock(AnnotatedMixin&, char const*, char const*, int, bool) 20#: (0x62349CE349CD) chain.h:225 - CBlockIndex::GetBlockPos() const 21#: (0x62349CE349CD) blockstorage.cpp:778 - operator() 22#: (0x62349CE349CD) blockstorage.cpp:778 - ReadBlockFromDisk(CBlock&, CBlockIndex const*, Consensus::Params const&) 23#: (0x62349D102F82) mnhftx.cpp:284 - CMNHFManager::GetForBlock(CBlockIndex const*) 24#: (0x62349D103E9B) mnhftx.cpp:58 - CMNHFManager::GetSignalsStage(CBlockIndex const*) 25#: (0x62349D07F0E9) versionbits.cpp:222 - SignalHeight 26#: (0x62349D07F90D) versionbits.cpp:37 - AbstractThresholdConditionChecker::GetStateFor(CBlockIndex const*, Consensus::Params const&, std::map, std::allocator > >&) const 27#: (0x62349D080D93) sync.h:199 - UniqueLock, std::unique_lock >::~UniqueLock() 28#: (0x62349D080D93) versionbits.cpp:260 - VersionBitsCache::State(CBlockIndex const*, Consensus::Params const&, Consensus::DeploymentPos) 29#: (0x62349CC06C73) deterministicmns.cpp:227 - CDeterministicMNList::GetProjectedMNPayees(gsl::not_null, int) const Aborted (core dumped) --- src/evo/mnhftx.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/evo/mnhftx.cpp b/src/evo/mnhftx.cpp index aef76cd96c..788d25f4fd 100644 --- a/src/evo/mnhftx.cpp +++ b/src/evo/mnhftx.cpp @@ -54,6 +54,8 @@ CMNHFManager::~CMNHFManager() CMNHFManager::Signals CMNHFManager::GetSignalsStage(const CBlockIndex* const pindexPrev) { + if (!DeploymentActiveAfter(pindexPrev, Params().GetConsensus(), Consensus::DEPLOYMENT_V20)) return {}; + Signals signals = GetForBlock(pindexPrev); if (pindexPrev == nullptr) return {}; const int height = pindexPrev->nHeight + 1;