2
0
mirror of https://github.com/wolfpld/tracy synced 2026-01-19 04:52:09 +00:00

Fix crash when reaching the source location limit

Instead of crashing when reaching the maximum number of source locations, display an empty source location ( with "???" everywhere).
Keeping the assert for discoverability of the limit in debug, but ensure profiler won't crash later on (or in release).
This commit is contained in:
Clément Grégoire
2025-05-12 13:49:31 +02:00
parent 53510c316b
commit c100b32b48

View File

@@ -2478,12 +2478,17 @@ const SourceLocation& Worker::GetSourceLocation( int16_t srcloc ) const
{
return *m_data.sourceLocationPayload[-srcloc-1];
}
else
else if( srcloc != std::numeric_limits<int16_t>::max() )
{
const auto it = m_data.sourceLocation.find( m_data.sourceLocationExpand[srcloc] );
assert( it != m_data.sourceLocation.end() );
return it->second;
}
else
{
static const SourceLocation emptySourceLoc = {};
return emptySourceLoc;
}
}
std::pair<const char*, const char*> Worker::GetExternalName( uint64_t id ) const
@@ -3347,6 +3352,9 @@ int16_t Worker::ShrinkSourceLocationReal( uint64_t srcloc )
int16_t Worker::NewShrinkedSourceLocation( uint64_t srcloc )
{
assert( m_data.sourceLocationExpand.size() < std::numeric_limits<int16_t>::max() );
if( ( m_data.sourceLocationExpand.size() + 1 ) == std::numeric_limits<int16_t>::max() )
return std::numeric_limits<int16_t>::max();
const auto sz = int16_t( m_data.sourceLocationExpand.size() );
m_data.sourceLocationExpand.push_back( srcloc );
#ifndef TRACY_NO_STATISTICS