Skip to content

Commit c2ae5ff

Browse files
TheBlueMattfurszy
authored andcommitted
Fix fast-shutdown crash if genesis block was not loaded
If the ShutdownRequested() check at the top of ActivateBestChain() returns false during initial genesis block load we will fail an assertion in UTXO DB flush as the best block hash IsNull(). To work around this, we move the check until after one round of ActivateBestChainStep(), ensuring the genesis block gets connected. Github-Pull: #2290 Rebased-From: 8640be1
1 parent 7ab7112 commit c2ae5ff

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/validation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,12 @@ bool ActivateBestChain(CValidationState& state, std::shared_ptr<const CBlock> pb
22762276
}
22772277
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
22782278

2279+
// We check shutdown only after giving ActivateBestChainStep a chance to run once so that we
2280+
// never shutdown before connecting the genesis block during LoadChainTip(). Previously this
2281+
// caused an assert() failure during shutdown in such cases as the UTXO DB flushing checks
2282+
// that the best block hash is non-null.
2283+
if (ShutdownRequested())
2284+
break;
22792285
} while (pindexMostWork != chainActive.Tip());
22802286

22812287
CheckBlockIndex();

0 commit comments

Comments
 (0)