Browse Source

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
pull/145/head
Gavin Andresen 11 years ago
parent
commit
d605bc4cd1
  1. 6
      src/init.cpp
  2. 3
      src/qt/bitcoin.cpp

6
src/init.cpp

@ -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();

3
src/qt/bitcoin.cpp

@ -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…
Cancel
Save