Skip to content

Commit

Permalink
Merge #12349: shutdown: fix crash on shutdown with reindex-chainstate
Browse files Browse the repository at this point in the history
Summary:
ceaefdd fix possible shutdown assertion with -reindex-shutdown (Cory Fields)

Pull request description:

  Fixes the assertion error reported here: bitcoin/bitcoin#12349 (comment)

Tree-SHA512: db8e2a275f92a99df7f17852d00eba6df996e412aa3ed3853a9ea0a8cb9800760677532efd52f92abbf2cdcc4210957a87a5f919ac998d46c205365a7a7dffca

Backport of Core PR 12349
https://github.com/bitcoin/bitcoin/pull/12349/files
Discovered while working on PR 12367 (D2906)
Depends on D2906

Test Plan:
`make check`

On master, apply this patch:
```
diff --git a/src/init.cpp b/src/init.cpp
index 56520fe..8d7371d 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -2139,6 +2139,7 @@ bool AppInitMain(Config &config,
                         break;
                     }
                 }
+                fRequestShutdown = true;

                 if (!fReindex && !fReindexChainState) {
                     uiInterface.InitMessage(_("Verifying blocks..."));
```
Then run:
`gdb --args ./src/bitcoind -connect=0 -testnet -reindex-chainstate`
A crash should be encountered.

Apply the same patch above on this diff and run the same command above.
GDB should report a successful program exit.

Reviewers: deadalnix, Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D2907
  • Loading branch information
laanwj authored and jasonbcox committed May 6, 2019
1 parent bb92536 commit ea00f38
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/validation.cpp
Expand Up @@ -2144,7 +2144,7 @@ static bool FlushStateToDisk(const CChainParams &chainparams,
}
// Flush best chain related state. This can only be done if the
// blocks / block index write was also done.
if (fDoFullFlush) {
if (fDoFullFlush && !pcoinsTip->GetBestBlock().IsNull()) {
// Typical Coin structures on disk are around 48 bytes in size.
// Pushing a new one to the database can cause it to be written
// twice (once in the log, and once in the tables). This is
Expand Down

0 comments on commit ea00f38

Please sign in to comment.