Exit cleanly if AppInit2 returns false
Bitcoin-Qt could core dump if application initialization failed in certain ways. I double-fixed this: 1) qt/bitcoin.cpp now shuts down core threads cleanly if AppInit2 returns false 2) init.cpp now exits before StartNode() if strErrors is set (no reason to StartNode if we're just going to exit immediately anyway). Tested by triggering all of the various ways AppInit2 can fail, either by passing bogus command-line arguments or just recompiling tweaked code to simulate failure. This is a partial fix for #2480
This commit is contained in:
parent
eef2091fe9
commit
d605bc4cd1
2 changed files with 6 additions and 3 deletions
|
@ -1033,6 +1033,9 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||
if (!CheckDiskSpace())
|
||||
return false;
|
||||
|
||||
if (!strErrors.str().empty())
|
||||
return InitError(strErrors.str());
|
||||
|
||||
RandAddSeedPerfmon();
|
||||
|
||||
//// debug print
|
||||
|
@ -1054,9 +1057,6 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||
|
||||
uiInterface.InitMessage(_("Done loading"));
|
||||
|
||||
if (!strErrors.str().empty())
|
||||
return InitError(strErrors.str());
|
||||
|
||||
// Add wallet transactions that aren't already in a block to mapTransactions
|
||||
pwalletMain->ReacceptWalletTransactions();
|
||||
|
||||
|
|
|
@ -271,6 +271,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
threadGroup.interrupt_all();
|
||||
threadGroup.join_all();
|
||||
Shutdown();
|
||||
return 1;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
|
|
Loading…
Reference in a new issue