Skip to content

GUI table sorts compare formatted display strings instead of numeric fields #88

Description

@rezdm

Problem

Several sort comparators in src/ui/imgui/imgui_details_tabs.cpp compare the human-readable display string instead of the numeric field that's already available on the struct:

  • Memory maps "Size" column (line ~421): `a.size.compare(b.size)` — compares strings like "100 KB" vs "2 MB" lexicographically ('1' < '2' as characters), giving visibly wrong ordering. `MemoryMapInfo::size_bytes` (the authoritative numeric value) exists and isn't used here.
  • Libraries "Base Address" column (line ~534): `a.base_address.compare(b.base_address)` — currently happens to sort correctly everywhere I checked because the hex string is fixed-width zero-padded (e.g. `{:016x}`), making lexicographic order coincide with numeric order, but it's fragile and should use `LibraryInfo::base_addr` (numeric) on principle.
  • Threads "TID" column (line ~293): `a.tid - b.tid` — subtraction-based compare can overflow for large/negative TIDs. This is a real, not just theoretical, risk: see the linked macOS TID-truncation issue, where thread IDs can already be negative.

Fix

Switch all three comparators to compare the numeric field directly with a proper three-way compare (`(a < b) ? -1 : (a > b) ? 1 : 0`, matching the pattern already used correctly elsewhere in the same file, e.g. Network's port columns).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions