mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-30 04:25:27 +00:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user