diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2013-05-02 12:26:33 -0400 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-05-02 12:26:33 -0400 |
commit | d605bc4cd13716fde9c34d79a01f4ee128f8814f (patch) | |
tree | d6fe14f8a9654b4eaa5b4df69e02fb6820c12b95 | |
parent | eef2091fe9ee39ecd8e874c91d3ab0ff023c5356 (diff) |
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
-rw-r--r-- | src/init.cpp | 6 | ||||
-rw-r--r-- | src/qt/bitcoin.cpp | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp index 3845cfad81..c2259f1d76 100644 --- a/src/init.cpp +++ b/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(); diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 25448ea8cf..a567eafd5c 100644 --- a/src/qt/bitcoin.cpp +++ b/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) { |