From 6ca1c986557201dab7370cac9f564ba69345f2b0 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 13 Oct 2022 00:14:35 +0200 Subject: [PATCH] Handle symbol thread crashes. Should the symbol thread crash, mark that it is gone. This will allow the profiler to transmit crash call stack, including resolved symbol names and locations (which will resolve on the main profiler thread). --- public/client/TracyProfiler.cpp | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/public/client/TracyProfiler.cpp b/public/client/TracyProfiler.cpp index 2af76b8f..b4eb9572 100644 --- a/public/client/TracyProfiler.cpp +++ b/public/client/TracyProfiler.cpp @@ -849,6 +849,19 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp ) } #endif +static Profiler* s_instance = nullptr; +static Thread* s_thread; +#ifndef TRACY_NO_FRAME_IMAGE +static Thread* s_compressThread; +#endif +#ifdef TRACY_HAS_CALLSTACK +static Thread* s_symbolThread; +std::atomic s_symbolThreadGone { false }; +#endif +#ifdef TRACY_HAS_SYSTEM_TRACING +static Thread* s_sysTraceThread = nullptr; +#endif + #if defined __linux__ && !defined TRACY_NO_CRASH_HANDLER # ifndef TRACY_CRASH_SIGNAL # define TRACY_CRASH_SIGNAL SIGPWR @@ -1067,10 +1080,10 @@ static void CrashHandler( int signal, siginfo_t* info, void* /*ucontext*/ ) } closedir( dp ); - { - TracyLfqPrepare( QueueType::Crash ); - TracyLfqCommit; - } + if( selfTid == s_symbolTid ) s_symbolThreadGone.store( true, std::memory_order_release ); + + TracyLfqPrepare( QueueType::Crash ); + TracyLfqCommit; std::this_thread::sleep_for( std::chrono::milliseconds( 500 ) ); GetProfiler().RequestShutdown(); @@ -1083,19 +1096,6 @@ static void CrashHandler( int signal, siginfo_t* info, void* /*ucontext*/ ) enum { QueuePrealloc = 256 * 1024 }; -static Profiler* s_instance = nullptr; -static Thread* s_thread; -#ifndef TRACY_NO_FRAME_IMAGE -static Thread* s_compressThread; -#endif -#ifdef TRACY_HAS_CALLSTACK -static Thread* s_symbolThread; -std::atomic s_symbolThreadGone { false }; -#endif -#ifdef TRACY_HAS_SYSTEM_TRACING -static Thread* s_sysTraceThread = nullptr; -#endif - TRACY_API int64_t GetFrequencyQpc() { #if defined _WIN32