When our chainstate activation sequence fails and we’re running the GUI, we ask the user via a question box whether or not they’d like to re-run the sequence with fReindex = true
. Fun fact: despite the fact that this sequence is wrapped in a while loop, we only run it twice at most.
If they answer yes, the sequence will always fail, because a chainstate will have already been initialized in the original run and InitializeChainstate
will throw a std::logic_error
:
This always reproduces. To reproduce:
0gdb ./src/qt/bitcoin-qt
1(gdb) b InitializeChainstate
2(gdb) # add breakpoint for the "if (!fLoaded && !ShutdownRequested()) {" line
3(gdb) r # should stop at the breakpoint for InitializeChainstate
4(gdb) c # to advance to the breakpoint for the "if (!fLoaded && !ShutdownRequested()) {" line
5(gdb) set fLoaded=false
6(gdb) c # should stop at the breakpoint for InitializeChainstate
7(gdb) n # step through InitializeChainstate to see that it throws
We expect the re-run of the chainstate activation sequence to not always fail.