From 03289175abbf6623af7180e13fa985e315afdd32 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 24 Oct 2017 22:02:49 +0200 Subject: [PATCH] Lock counter also must be initialized early. --- client/TracyLock.hpp | 2 +- client/TracyProfiler.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/TracyLock.hpp b/client/TracyLock.hpp index 182a1bd6..5f41ce23 100644 --- a/client/TracyLock.hpp +++ b/client/TracyLock.hpp @@ -10,7 +10,7 @@ namespace tracy { -static std::atomic s_lockCounter( 0 ); +extern std::atomic s_lockCounter; template class Lockable diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 20d53cb0..7914632e 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -78,11 +78,11 @@ static unsigned int __dontcare_cpu; // 1a. But s_queue is needed for initialization of variables in point 2. extern moodycamel::ConcurrentQueue s_queue; -static thread_local RPMallocThreadInit init_order(105) s_rpmalloc_thread_init; +static thread_local RPMallocThreadInit init_order(106) s_rpmalloc_thread_init; // 2. If these variables would be in the .CRT$XCB section, they would be initialized only in main thread. -static thread_local moodycamel::ProducerToken init_order(106) s_token_detail( s_queue ); -thread_local ProducerWrapper init_order(107) s_token { s_queue.get_explicit_producer( s_token_detail ) }; +static thread_local moodycamel::ProducerToken init_order(107) s_token_detail( s_queue ); +thread_local ProducerWrapper init_order(108) s_token { s_queue.get_explicit_producer( s_token_detail ) }; #ifdef _MSC_VER // 1. Initialize these static variables before all other variables. @@ -93,7 +93,8 @@ thread_local ProducerWrapper init_order(107) s_token { s_queue.get_explicit_prod static InitTimeWrapper init_order(101) s_initTime { Profiler::GetTime( __dontcare_cpu ) }; static RPMallocInit init_order(102) s_rpmalloc_init; moodycamel::ConcurrentQueue init_order(103) s_queue( QueuePrealloc ); -static Profiler init_order(104) s_profiler; +std::atomic init_order(104) s_lockCounter( 0 ); +static Profiler init_order(105) s_profiler; Profiler::Profiler()