The problem: Init.makeMining returns as soon as the chainstate is loaded. On a first start with an empty datadir, or on a node started with -reindex/-reindex-chainstate, this is before the genesis block is connected, so the active chain has no tip. A Mining.checkBlock call in this window reaches TestBlockValidity(), which asserts that the tip exists, and the node aborts.
The fix: in MakeMining, if wait_loaded is set, wait for the chainstate to be present and for the tip to be non-null.
Alternative fix: In Mining.checkBlock, check if the tip is present, return early with "inconclusive-no-chain-tip" otherwise. (I initially implemented this fix, but decided to go with the makeMining one instead, see #36908 (review))
The crash can be reproduced on master using the functional test included in this PR.
This is joint work with Turtlecute33 :)