From d74d77226c65ff6412e4c6c94bf2e620ca37e8c3 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 25 Jul 2026 16:43:43 +0200 Subject: [PATCH] Guard against empty synthetic call stacks in parents frame trees. A sample with a single-frame call stack already produces a zero-length parent stack, and GetParentsCallstackFrameTree{BottomUp,TopDown} call cs.back() / cs.front() on it, resulting in UB. --- profiler/src/profiler/TracyView_FrameTree.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/profiler/src/profiler/TracyView_FrameTree.cpp b/profiler/src/profiler/TracyView_FrameTree.cpp index 8ab142bb..f664ebb4 100644 --- a/profiler/src/profiler/TracyView_FrameTree.cpp +++ b/profiler/src/profiler/TracyView_FrameTree.cpp @@ -248,6 +248,7 @@ unordered_flat_map View::GetParentsCallstackFrameT for( auto& path : stacks ) { auto& cs = m_worker.GetSyntheticCallstack( path.first ); + if( cs.empty() ) continue; auto base = cs.back(); auto treePtr = GetParentFrameTreeItemGroup( root, base, m_worker ); if( treePtr ) @@ -267,6 +268,7 @@ unordered_flat_map View::GetParentsCallstackFrameT for( auto& path : stacks ) { auto& cs = m_worker.GetSyntheticCallstack( path.first ); + if( cs.empty() ) continue; auto base = cs.back(); auto treePtr = GetFrameTreeItemNoGroup( root, base ); treePtr->count += path.second; @@ -378,6 +380,7 @@ unordered_flat_map View::GetParentsCallstackFrameT for( auto& path : stacks ) { auto& cs = m_worker.GetSyntheticCallstack( path.first ); + if( cs.empty() ) continue; auto base = cs.front(); auto treePtr = GetParentFrameTreeItemGroup( root, base, m_worker ); if( treePtr ) @@ -397,6 +400,7 @@ unordered_flat_map View::GetParentsCallstackFrameT for( auto& path : stacks ) { auto& cs = m_worker.GetSyntheticCallstack( path.first ); + if( cs.empty() ) continue; auto base = cs.front(); auto treePtr = GetFrameTreeItemNoGroup( root, base ); treePtr->count += path.second;