From 7a436e1463b1d03718d7689e2aa632bcde64767c Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 23 Sep 2019 12:02:46 +0100 Subject: [PATCH] Ensure logging locks aren't destroyed too early * If these static locks are destroyed before other things at shutdown, logging may crash. We can just leak them since they should survive until process shutdown (where it's fine to leak) --- renderdoc/common/common.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/renderdoc/common/common.cpp b/renderdoc/common/common.cpp index fa480c317..2b9d71dd7 100644 --- a/renderdoc/common/common.cpp +++ b/renderdoc/common/common.cpp @@ -348,9 +348,9 @@ void rdclog_flush() void rdclogprint_int(LogType type, const char *fullMsg, const char *msg) { - static Threading::CriticalSection lock; + static Threading::CriticalSection *lock = new Threading::CriticalSection(); - SCOPED_LOCK(lock); + SCOPED_LOCK(*lock); #if ENABLED(OUTPUT_LOG_TO_DEBUG_OUT) OSUtility::WriteOutput(OSUtility::Output_DebugMon, fullMsg); @@ -412,9 +412,9 @@ void rdclog_direct(time_t utcTime, uint32_t pid, LogType type, const char *proje "Debug ", "Log ", "Warning", "Error ", "Fatal ", }; - static Threading::CriticalSection lock; + static Threading::CriticalSection *lock = new Threading::CriticalSection(); - SCOPED_LOCK(lock); + SCOPED_LOCK(*lock); rdclog_outputBuffer[rdclog_outBufSize] = rdclog_outputBuffer[0] = 0;