Skip to content

macOS: thread IDs display as negative (uint64_t thread port truncated to int) #95

Description

@rezdm

Problem

`MacosProcessDataProvider::get_threads()` (src/platform/macos/macos_process_details.cpp:100) does:
```cpp
t.tid = static_cast(tids[i]);
```
where `tids[i]` is a `uint64_t` thread ID/Mach thread port returned by `proc_pidinfo(PROC_PIDLISTTHREADS)`. Values above `INT_MAX` truncate to negative when narrowed to a 32-bit signed `int` — confirmed on real hardware (reported by a tester: negative thread IDs shown in the Threads tab on macOS).

This is also the root cause behind a related sort-comparator bug: the Threads table sorts TID via subtraction (`a.tid - b.tid`, src/ui/imgui/imgui_details_tabs.cpp), which can itself overflow/misbehave once TIDs can be large or negative.

Fix

Widen `ThreadInfo::tid` (src/core/model/process_info.hpp) from `int` to `int64_t`, and `IProcessDataProvider::get_thread_stack`'s `tid` parameter to match, across the shared interface and all platform implementations (Linux/FreeBSD/Solaris/Windows TIDs all fit comfortably in int64_t, so this is a widening with no other platform impact). Also fix the Threads sort comparator to a proper three-way compare instead of subtraction (tracked together with the other sort-comparator fixes in #88, but the type change belongs here since it's macOS-specific root cause).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmacosmacOS platform backend

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions