Fix races in rpmalloc initialization.

Ensure rpmalloc_thread_initialize() int worker threads is called only after
rpmalloc_initialize() was called on the main profiler thread.
This commit is contained in:
Bartosz Taudul 2019-07-19 19:25:27 +02:00
parent cef8124247
commit 4c28593031

View File

@ -1179,6 +1179,8 @@ void Profiler::Worker()
s_profilerTid = syscall( SYS_gettid ); s_profilerTid = syscall( SYS_gettid );
#endif #endif
while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
rpmalloc_thread_initialize(); rpmalloc_thread_initialize();
const auto procname = GetProcessName(); const auto procname = GetProcessName();
@ -1187,8 +1189,6 @@ void Profiler::Worker()
const auto hostinfo = GetHostInfo(); const auto hostinfo = GetHostInfo();
const auto hisz = std::min<size_t>( strlen( hostinfo ), WelcomeMessageHostInfoSize - 1 ); const auto hisz = std::min<size_t>( strlen( hostinfo ), WelcomeMessageHostInfoSize - 1 );
while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
#ifdef TRACY_ON_DEMAND #ifdef TRACY_ON_DEMAND
uint8_t onDemand = 1; uint8_t onDemand = 1;
#else #else
@ -1517,6 +1517,7 @@ void Profiler::Worker()
void Profiler::CompressWorker() void Profiler::CompressWorker()
{ {
while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
rpmalloc_thread_initialize(); rpmalloc_thread_initialize();
for(;;) for(;;)
{ {