Skip to content

Commit

Permalink
fix: possible deadlock during calculation of signals for historical b…
Browse files Browse the repository at this point in the history
…locks 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<unsigned long, std::allocator<unsigned long> >::_Vector_impl_data::_M_copy_data(std::_Vector_base<unsigned long, std::allocator<unsigned long> >::_Vector_impl_data const&)
       1#: (0x62349D233974) stl_vector.h:127         - std::_Vector_base<unsigned long, std::allocator<unsigned long> >::_Vector_impl_data::_M_swap_data(std::_Vector_base<unsigned long, std::allocator<unsigned long> >::_Vector_impl_data&)
       2#: (0x62349D233974) stl_vector.h:1959        - std::vector<unsigned long, std::allocator<unsigned long> >::_M_move_assign(std::vector<unsigned long, std::allocator<unsigned long> >&&, std::integral_constant<bool, true>)
       3#: (0x62349D233974) stl_vector.h:768         - std::vector<unsigned long, std::allocator<unsigned long> >::operator=(std::vector<unsigned long, std::allocator<unsigned long> >&&)
       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<char, std::char_traits<char>, std::allocator<char> >::_M_check_length(unsigned long, unsigned long, char const*) const
      12#: (0x62349D239956) basic_string.h:1461      - std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::append(char const*)
      13#: (0x62349D239956) basic_string.h:1365      - std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)
      14#: (0x62349D239956) sync.cpp:114             - potential_deadlock_detected
      15#: (0x62349D2403DE) sync.cpp:188             - push_lock<std::recursive_mutex>
      16#: (0x62349D2403DE) sync.cpp:212             - void EnterCritical<std::recursive_mutex>(char const*, char const*, int, std::recursive_mutex*, bool)
      17#: (0x62349CAA8B72) unique_lock.h:150        - std::unique_lock<std::recursive_mutex>::try_lock()
      18#: (0x62349CAA8B72) sync.h:162               - UniqueLock<AnnotatedMixin<std::recursive_mutex>, std::unique_lock<std::recursive_mutex> >::Enter(char const*, char const*, int)
      19#: (0x62349CAA8B72) sync.h:183               - UniqueLock<AnnotatedMixin<std::recursive_mutex>, std::unique_lock<std::recursive_mutex> >::UniqueLock(AnnotatedMixin<std::recursive_mutex>&, 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<CBlockIndex const*, ThresholdState, std::less<CBlockIndex const*>, std::allocator<std::pair<CBlockIndex const* const, ThresholdState> > >&) const
      27#: (0x62349D080D93) sync.h:199               - UniqueLock<AnnotatedMixin<std::mutex>, std::unique_lock<std::mutex> >::~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<CBlockIndex const* const>, int) const
    Aborted (core dumped)
  • Loading branch information
knst committed Aug 23, 2024
1 parent 4f87022 commit f8a4893
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/evo/mnhftx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f8a4893

Please sign in to comment.