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.
This commit is contained in:
Bartosz Taudul
2026-07-25 16:43:43 +02:00
parent 8f52e0e5f5
commit d74d77226c

View File

@@ -248,6 +248,7 @@ unordered_flat_map<uint64_t, CallstackFrameTree> 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<uint64_t, CallstackFrameTree> 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<uint64_t, CallstackFrameTree> 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<uint64_t, CallstackFrameTree> 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;