Detect zone end without begin failure.

This commit is contained in:
Bartosz Taudul 2019-01-16 00:45:48 +01:00
parent 7b6b6862ed
commit 49e270d8a6
2 changed files with 15 additions and 2 deletions

View File

@ -2277,10 +2277,13 @@ void Worker::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev )
void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
{ {
auto tit = m_threadMap.find( ev.thread ); 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; auto td = tit->second;
assert( !td->zoneIdStack.empty() );
auto zoneId = td->zoneIdStack.back_and_pop(); auto zoneId = td->zoneIdStack.back_and_pop();
if( zoneId != td->nextZoneId ) if( zoneId != td->nextZoneId )
{ {
@ -2329,6 +2332,13 @@ void Worker::ZoneStackFailure( uint64_t thread, const ZoneEvent* ev )
m_failureData.srcloc = ev->srcloc; 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 ) void Worker::MemFreeFailure( uint64_t thread )
{ {
m_failure = Failure::MemFree; m_failure = Failure::MemFree;
@ -3655,6 +3665,7 @@ void Worker::WriteTimeline( FileWrite& f, const Vector<GpuEvent*>& vec, int64_t&
static const char* s_failureReasons[] = { static const char* s_failureReasons[] = {
"<unknown reason>", "<unknown reason>",
"Invalid order of zone begin and end events.", "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." "Memory free event without a matching allocation."
}; };

View File

@ -181,6 +181,7 @@ public:
{ {
None, None,
ZoneStack, ZoneStack,
ZoneEnd,
MemFree, MemFree,
NUM_FAILURES NUM_FAILURES
@ -335,6 +336,7 @@ private:
tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev ); tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev );
void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev ); void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev );
void ZoneEndFailure( uint64_t thread );
void MemFreeFailure( uint64_t thread ); void MemFreeFailure( uint64_t thread );
tracy_force_inline void CheckSourceLocation( uint64_t ptr ); tracy_force_inline void CheckSourceLocation( uint64_t ptr );