Skip to content

Commit

Permalink
Fix fast-shutdown crash if genesis block was not loaded
Browse files Browse the repository at this point in the history
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
  • Loading branch information
TheBlueMatt authored and furszy committed Apr 8, 2021
1 parent 7ab7112 commit c2ae5ff
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,12 @@ bool ActivateBestChain(CValidationState& state, std::shared_ptr<const CBlock> pb
}
// When we reach this point, we switched to a new tip (stored in pindexNewTip).

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

CheckBlockIndex();
Expand Down

0 comments on commit c2ae5ff

Please sign in to comment.