[PATCH v3 1/4] perf ui hists: In report UI ensure thread is set

From: Ian Rogers

Date: Thu Jul 09 2026 - 12:53:16 EST


A map_symbol contains a thread that provides access to the wider perf
session. Recent changes used the thread to get the e_machine to better
support cross-platform disassembly. Unfortunately the UI code wasn't
populating the thread and so the e_machine lookup failed early
breaking the 'a' for annotate TUI action. Populate the map_symbol
thread to fix this.

Note: For the popup_action array, we intentionally do NOT use
thread__get() or map__get() when assigning to ms.thread and
ms.map. The actions array has a strictly bounded lifecycle that does
not outlive the menu loop, making raw pointers safe. If we took
references, we would have to clean them up (e.g., via
map_symbol__exit()), which if erroneously applied to raw pointers
would incorrectly drop references owned by the caller and lead to a
use-after-free.

Reported-by: Josh Stone <jistone@xxxxxxxxxx>
Fixes: 0e26ba5a8774 ("perf disasm: Refactor arch__find and initialization of arch structs")
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/ui/browsers/hists.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index da7cc195b9f4..f8ffd9b73582 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -3155,10 +3155,12 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *h
continue;

actions->ms.sym = symbol__new_unresolved(bi->to.al_addr, bi->to.ms.map);
+ actions->ms.thread = bi->to.ms.thread;
actions->ms.map = bi->to.ms.map;
} else {
actions->ms.sym = symbol__new_unresolved(browser->he_selection->ip,
browser->selection->map);
+ actions->ms.thread = browser->selection->thread;
actions->ms.map = browser->selection->map;
}

@@ -3173,6 +3175,7 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *h
continue;
}

+ actions->ms.thread = browser->selection->thread;
actions->ms.map = browser->selection->map;
actions->ms.sym = browser->selection->sym;
}
--
2.55.0.795.g602f6c329a-goog