Mercurial > hg > bitcoin
changeset 3611:5308ff68698a draft
Merge branch 'crash_at_exit' of github.com:gavinandresen/bitcoin-git
author | Gavin Andresen <gavinandresen@gmail.com> |
---|---|
date | Tue, 09 Oct 2012 12:10:18 -0400 |
parents | eb2790dc6d37 (current diff) e82d99c8b1b0 (diff) |
children | e34485ae790c |
files | |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/util.cpp +++ b/src/util.cpp @@ -220,8 +220,14 @@ if (fileout) { static bool fStartedNewLine = true; - static boost::mutex mutexDebugLog; - boost::mutex::scoped_lock scoped_lock(mutexDebugLog); + + // This routine may be called by global destructors during shutdown. + // Since the order of destruction of static/global objects is undefined, + // allocate mutexDebugLog on the heap the first time this routine + // is called to avoid crashes during shutdown. + static boost::mutex* mutexDebugLog = NULL; + if (mutexDebugLog == NULL) mutexDebugLog = new boost::mutex(); + boost::mutex::scoped_lock scoped_lock(*mutexDebugLog); // reopen the log file, if requested if (fReopenDebugLog) {