aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2012-10-09 23:16:24 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2012-10-09 23:16:24 +0000
commitcef36fad891fba0fd8f5aec73bb17135b7fb133a (patch)
tree43eeae2dd9003ae894603bbb315ee2c3e40b9097 /src/util.cpp
parenta7642282f6465f2d9e2091ec6279fa1db1241cf3 (diff)
parentb3f8f6ab9409d3e901d22c09b0346a5a47779496 (diff)
downloadbitcoin-cef36fad891fba0fd8f5aec73bb17135b7fb133a.tar.xz
Merge branch '0.4.x' into 0.5.x
Conflicts: src/bitcoinrpc.cpp src/init.cpp
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/util.cpp b/src/util.cpp
index d496a44d2d..61257e667e 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -194,8 +194,14 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
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);
// Debug print useful for profiling
if (fLogTimestamps && fStartedNewLine)