From 2f2d8a7ba915125af6eefe54f3c1217bb1a7c077 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 30 Aug 2026 16:44:01 +0200 Subject: [PATCH] Fail when system tracing fails to start. IsSystemTracingFailed reports a SysTraceStart that the preflight could not predict (the target exiting between the checks, the kernel rejecting the event setup); starting anyway would capture no samples. --- monitor/src/monitor.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/monitor/src/monitor.cpp b/monitor/src/monitor.cpp index d7300f58..168a2bc0 100644 --- a/monitor/src/monitor.cpp +++ b/monitor/src/monitor.cpp @@ -483,6 +483,12 @@ static int RunAttached( pid_t pid ) if( !PreflightSamplingEvent( pid, kernelFrames, hwStats, hwErrno ) ) return 1; tracy::StartupProfiler(); + if( tracy::IsSystemTracingFailed() ) + { + fprintf( stderr, "The client failed to start sampling although the preflight passed; the capture would contain no samples (the target may have exited between checks, or the kernel rejected the event setup).\n" ); + tracy::ShutdownProfiler(); + return 1; + } if( !VerifyClientListening() ) { if( const char* port = getenv( "TRACY_PORT" ) ) @@ -603,6 +609,14 @@ static int RunForked( int argc, char** argv ) } tracy::StartupProfiler(); + if( tracy::IsSystemTracingFailed() ) + { + fprintf( stderr, "The client failed to start sampling although the preflight passed; the capture would contain no samples (the target may have exited between checks, or the kernel rejected the event setup).\n" ); + kill( childPid, SIGKILL ); + waitpid( childPid, nullptr, 0 ); + tracy::ShutdownProfiler(); + return 1; + } // Detach ptrace and let the child run. If detach fails the child stays // stopped forever, so this has to be fatal.