From 61c9e8e6d89d1699e12b8c4ef629b0731bdba8ea Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 25 Jul 2021 11:46:20 +0200 Subject: [PATCH] Crash handler may be not installed. --- client/TracyProfiler.cpp | 20 +++++++++++++------- client/TracyProfiler.hpp | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index afaf6fda..ecc90d88 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1173,6 +1173,7 @@ Profiler::Profiler() #endif , m_paramCallback( nullptr ) , m_queryData( nullptr ) + , m_crashHandlerInstalled( false ) { assert( !s_instance ); s_instance = this; @@ -1249,6 +1250,8 @@ void Profiler::SpawnWorkerThreads() sigaction( SIGABRT, &crashHandler, &m_prevSignal.abrt ); #endif + m_crashHandlerInstalled = true; + #ifdef TRACY_HAS_CALLSTACK InitCallstack(); #endif @@ -1261,13 +1264,16 @@ Profiler::~Profiler() m_shutdown.store( true, std::memory_order_relaxed ); #ifdef __linux__ - sigaction( SIGPWR, &m_prevSignal.pwr, nullptr ); - sigaction( SIGILL, &m_prevSignal.ill, nullptr ); - sigaction( SIGFPE, &m_prevSignal.fpe, nullptr ); - sigaction( SIGSEGV, &m_prevSignal.segv, nullptr ); - sigaction( SIGPIPE, &m_prevSignal.pipe, nullptr ); - sigaction( SIGBUS, &m_prevSignal.bus, nullptr ); - sigaction( SIGABRT, &m_prevSignal.abrt, nullptr ); + if( m_crashHandlerInstalled ) + { + sigaction( SIGPWR, &m_prevSignal.pwr, nullptr ); + sigaction( SIGILL, &m_prevSignal.ill, nullptr ); + sigaction( SIGFPE, &m_prevSignal.fpe, nullptr ); + sigaction( SIGSEGV, &m_prevSignal.segv, nullptr ); + sigaction( SIGPIPE, &m_prevSignal.pipe, nullptr ); + sigaction( SIGBUS, &m_prevSignal.bus, nullptr ); + sigaction( SIGABRT, &m_prevSignal.abrt, nullptr ); + } #endif #ifdef TRACY_HAS_SYSTEM_TRACING diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 1a7de6d5..8a0f827d 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -817,6 +817,7 @@ private: struct sigaction pwr, ill, fpe, segv, pipe, bus, abrt; } m_prevSignal; #endif + bool m_crashHandlerInstalled; }; }