From 4af26880dda663bd452aeca06e13de1050a4f2ee Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 2 Jan 2020 22:39:05 +0100 Subject: [PATCH] Don't report CPU topology if delayed init is active. Reporting topology requires producer to be available, which creates a deadlock during delayed init data structures construction. Calling GetProducer() results in a call to GetProfilerThreadData(), which in turn calls GetProfilerData() to construct its thread local variable. However, at this point we already are calling GetProfilerData() (to construct the profiler itself). This would result in an incorrect double construction of data, but the code already prevents this by allowing init code to be entered only once. Hence the deadlock. Currently this is a non-issue, as no platform which can report CPU topology needs to use delayed init. --- client/TracyProfiler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index a8e02abe..983edf24 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -2441,6 +2441,7 @@ void Profiler::CalibrateDelay() void Profiler::ReportTopology() { +#ifndef TRACY_DELAYED_INIT struct CpuData { uint32_t package; @@ -2579,6 +2580,7 @@ void Profiler::ReportTopology() tracy_free( cpuData ); #endif +#endif } void Profiler::SendCallstack( int depth, const char* skipBefore )