From 0c13fb818b5495b0a119eaba80eb76ba0e4ef518 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 21 Jun 2018 17:02:40 +0200 Subject: [PATCH] Initialize rpmalloc in Mem{Alloc,Free}Callstack(). rpmalloc may still be uninitialized here (i.e. if memory allocation/free is performed before any other tracy operation that would initialize thread_local data). Since memory allocations are using serialized queue (which is not held in thread_local section) and obtaining callstack involves memory allocation, we need to initialize rpmalloc manually. This won't be a problem when support for zone callbacks becomes online, because zones are stored in per-thread queues, which initialize thread_local data before rpmalloc is needed in the Callstack() call. --- client/TracyProfiler.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index f262d5e7..e58ae3e6 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -220,6 +220,7 @@ public: { const auto thread = GetThreadHandle(); + rpmalloc_thread_initialize(); s_profiler.m_serialLock.lock(); SendMemAlloc( QueueType::MemAllocCallstack, thread, ptr, size ); SendCallstackMemory( depth ); @@ -230,6 +231,7 @@ public: { const auto thread = GetThreadHandle(); + rpmalloc_thread_initialize(); s_profiler.m_serialLock.lock(); SendMemFree( QueueType::MemFreeCallstack, thread, ptr ); SendCallstackMemory( depth );