diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 4d09f8c4..ae9a5818 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2277,10 +2277,13 @@ void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev ) void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) { auto tit = m_threadMap.find( ev.thread ); - assert( tit != m_threadMap.end() ); + if( tit == m_threadMap.end() || tit->second->zoneIdStack.empty() ) + { + ZoneEndFailure( ev.thread ); + return; + } auto td = tit->second; - assert( !td->zoneIdStack.empty() ); auto zoneId = td->zoneIdStack.back_and_pop(); if( zoneId != td->nextZoneId ) { @@ -2329,6 +2332,13 @@ void Worker::ZoneStackFailure( uint64_t thread, const ZoneEvent* ev ) m_failureData.srcloc = ev->srcloc; } +void Worker::ZoneEndFailure( uint64_t thread ) +{ + m_failure = Failure::ZoneEnd; + m_failureData.thread = thread; + m_failureData.srcloc = 0; +} + void Worker::MemFreeFailure( uint64_t thread ) { m_failure = Failure::MemFree; @@ -3655,6 +3665,7 @@ void Worker::WriteTimeline( FileWrite& f, const Vector& vec, int64_t& static const char* s_failureReasons[] = { "", "Invalid order of zone begin and end events.", + "Received zone end event without a matching zone begin event.", "Memory free event without a matching allocation." }; diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index b503d409..c04d21cb 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -181,6 +181,7 @@ public: { None, ZoneStack, + ZoneEnd, MemFree, NUM_FAILURES @@ -335,6 +336,7 @@ private: tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev ); void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev ); + void ZoneEndFailure( uint64_t thread ); void MemFreeFailure( uint64_t thread ); tracy_force_inline void CheckSourceLocation( uint64_t ptr );