Category may exist while sections are not filled.

Dereference of end() iterator in section category options list
(profiler/src/profiler/TracyView_Options.cpp:152-153)

The new category list iterates categories = m_worker.GetSectionDescriptions()
(the description map) and then looks up each category in sections = m_worker.
GetSections():

for( const auto& v : categories )
{
    ...
    auto it = sections.find( v.first );
    ImGui::TextDisabled( "(%s)", RealToString( it->second.size() ) );
    ...
}

sectionsDescription is a superset of sections's keys: ProcessSectionSetup
(server/TracyWorker.cpp:7484-7496) inserts into sectionsDescription only,
while ProcessSectionEnter (server/TracyWorker.cpp:7416-7454) inserts into
both. A category set up via TracySectionSetup that has no TracySectionEnter
events yet (or a saved trace containing such a category) will be in
sectionsDescription but not in sections. find returns end() and
it->second.size() is undefined behavior (likely crash).
This commit is contained in:
Bartosz Taudul
2026-07-14 21:21:45 +02:00
parent a501117392
commit ff3c57c8d3
+1 -1
View File
@@ -150,7 +150,7 @@ void View::DrawOptions()
SmallCheckbox( m_worker.GetSectionCategoryDescription( v.first ), &Vis( v.first ) );
ImGui::SameLine();
auto it = sections.find( v.first );
ImGui::TextDisabled( "(%s)", RealToString( it->second.size() ) );
if( it != sections.end() ) ImGui::TextDisabled( "(%s)", RealToString( it->second.size() ) );
ImGui::PopID();
}
ImGui::TreePop();