From b74caae685085e5f698f89a0148fdb3f1f70c2a5 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 30 Apr 2020 19:05:13 +0200 Subject: [PATCH] Handle ending a zone twice. --- server/TracyWorker.cpp | 13 +++++++++++++ server/TracyWorker.hpp | 2 ++ 2 files changed, 15 insertions(+) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 5c97fd59..404aac2a 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -4337,6 +4337,11 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) auto td = m_threadCtxData; assert( td ); + if( td->zoneIdStack.empty() ) + { + ZoneDoubleEndFailure( m_threadCtx, td->timeline.empty() ? nullptr : td->timeline.back() ); + return; + } auto zoneId = td->zoneIdStack.back_and_pop(); if( zoneId != td->nextZoneId ) { @@ -4422,6 +4427,13 @@ void Worker::ZoneStackFailure( uint64_t thread, const ZoneEvent* ev ) m_failureData.srcloc = ev->SrcLoc(); } +void Worker::ZoneDoubleEndFailure( uint64_t thread, const ZoneEvent* ev ) +{ + m_failure = Failure::ZoneDoubleEnd; + m_failureData.thread = thread; + m_failureData.srcloc = ev ? ev->SrcLoc() : 0; +} + void Worker::ZoneTextFailure( uint64_t thread ) { m_failure = Failure::ZoneText; @@ -7215,6 +7227,7 @@ void Worker::WriteTimelineImpl( FileWrite& f, const V& vec, int64_t& refTime, in static const char* s_failureReasons[] = { "", "Invalid order of zone begin and end events.", + "Zone is ended twice.", "Zone text transfer destination doesn't match active zone.", "Zone name transfer destination doesn't match active zone.", "Memory free event without a matching allocation.", diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index c1aff82d..ca93ba6e 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -349,6 +349,7 @@ public: { None, ZoneStack, + ZoneDoubleEnd, ZoneText, ZoneName, MemFree, @@ -615,6 +616,7 @@ private: tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev, bool serial ); void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev ); + void ZoneDoubleEndFailure( uint64_t thread, const ZoneEvent* ev ); void ZoneTextFailure( uint64_t thread ); void ZoneNameFailure( uint64_t thread ); void MemFreeFailure( uint64_t thread );