From 7e295f8b7875d5f2aa41d7c457d28a588c6fe025 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 29 Sep 2023 00:33:32 +0700 Subject: [PATCH] fix: possible assert call if nHeight in CDeterministicMNListDiff is higher than Tip Example of new log: ``` 2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159 ``` instead assert call: ``` ... #6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730, function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101 #7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=) at llmq/utils.cpp:730 #8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=, nCount@entry=2147483647) at evo/deterministicmns.cpp:231 #9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216 #10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194 #11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157 #12 0x000055555684a60f in void doActivate(QObject*, int, void**) () #13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) () #14 0x0000555556844ce5 in QObject::event(QEvent*) () #15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () #16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) () #17 0x000055555686de2a in QTimerInfoList::activateTimers() () #18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags) () #19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags) () #20 0x000055555681caf6 in QEventLoop::exec(QFlags) () #21 0x0000555556825f8a in QCoreApplication::exec() () ... ``` --- src/evo/deterministicmns.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index ad0e01b7ba5fb8..28884326473b79 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -213,7 +213,12 @@ CDeterministicMNCPtr CDeterministicMNList::GetMNPayee(const CBlockIndex* pIndex) std::vector CDeterministicMNList::GetProjectedMNPayeesAtChainTip(int nCount) const { - return GetProjectedMNPayees(::ChainActive()[nHeight], nCount); + const CBlockIndex* const pindex = ::ChainActive()[nHeight]; + if (pindex == nullptr) { + LogPrintf("GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=%lld chain height=%lld\n", nHeight, ::ChainActive().Tip()->nHeight); + return {}; + } + return GetProjectedMNPayees(pindex, nCount); } std::vector CDeterministicMNList::GetProjectedMNPayees(const CBlockIndex* const pindex, int nCount) const