From 0cf5416f48be1198da1561897d77bbc203693164 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 17 Sep 2026 23:32:48 -0700 Subject: [PATCH] perf trace: Free the host machine allocation trace__symbols_init() creates the host machine with machine__new_host(), which allocates a struct machine, but trace__symbols__exit() released it with machine__exit(). That tears down the contents of the machine and leaves the allocation itself behind, so use machine__delete(), which does both. The replay path points trace->host at the machine embedded in the session and never reaches here, so nothing else is affected. The leak was hidden from leak sanitizer because trace__symbols_init() passes the machine to trace_event__register_resolver(), which stores it as the private pointer of the global tep handle. The handle kept the machine reachable for as long as the process lived, so it was only once the handle started being freed that this was reported: Direct leak of 1256 byte(s) in 1 object(s) allocated from: #1 __machine__new_host util/machine.c:135 #2 machine__new_host util/machine.c:155 #3 trace__symbols_init builtin-trace.c:2105 #4 trace__run builtin-trace.c:4759 #5 cmd_trace builtin-trace.c:6091 Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 7fe39455085f..9b450c96469d 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2138,7 +2138,7 @@ static int trace__symbols_init(struct trace *trace, int argc, const char **argv, static void trace__symbols__exit(struct trace *trace) { - machine__exit(trace->host); + machine__delete(trace->host); trace->host = NULL; perf_env__exit(&trace->host_env);