When disabling the “test-only” assumptions in CheckBlockIndex, the check fails. This is problematic, because test-only code should not affect the behavior of the program in production.
Current diff:
0diff --git a/src/validation.cpp b/src/validation.cpp
1index 8c583c586c..00d7ee3736 100644
2--- a/src/validation.cpp
3+++ b/src/validation.cpp
4@@ -4866,9 +4866,9 @@ void ChainstateManager::CheckBlockIndex()
5 unsigned int prev_chain_tx = pindex->pprev ? pindex->pprev->nChainTx : 0;
6 assert((pindex->nChainTx == pindex->nTx + prev_chain_tx)
7 // For testing, allow transaction counts to be completely unset.
8- || (pindex->nChainTx == 0 && pindex->nTx == 0)
9+ //|| (pindex->nChainTx == 0 && pindex->nTx == 0)
10 // For testing, allow this nChainTx to be unset if previous is also unset.
11- || (pindex->nChainTx == 0 && prev_chain_tx == 0 && pindex->pprev)
12+ //|| (pindex->nChainTx == 0 && prev_chain_tx == 0 && pindex->pprev)
13 // Transaction counts prior to snapshot are unknown.
14 || pindex->IsAssumedValid());
15
Steps to reproduce the crash:
0$ ./src/qt/bitcoin-qt -datadir=/tmp -regtest
1> generatetodescriptor 1 raw(ff)
Related to #28791 and #28562 (review)