Skip to content

Commit 1e24ce4

Browse files
bengaineyarmacmel
authored andcommitted
perf db-export: Fix missing reference count get in call_path_from_sample()
The addr_location map and maps fields in the inner loop were missing calls to map__get()/maps__get(). The subsequent addr_location__exit() call in each loop puts the map/maps fields causing use-after-free aborts. This issue reproduces on at least arm64 and x86_64 with something simple like `perf record -g ls` followed by `perf script -s script.py` with the following script: perf_db_export_mode = True perf_db_export_calls = False perf_db_export_callchains = True def sample_table(*args): print(f'sample_table({args})') def call_path_table(*args): print(f'call_path_table({args}') Committer testing: This test, just introduced by Ian Rogers, now passes, not segfaulting anymore: # perf test "perf script tests" 95: perf script tests : Ok # Fixes: 0dd5041 ("perf addr_location: Add init/exit/copy functions") Signed-off-by: Ben Gainey <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Tested-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent bb177a8 commit 1e24ce4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/perf/util/db-export.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ static struct call_path *call_path_from_sample(struct db_export *dbe,
253253
*/
254254
addr_location__init(&al);
255255
al.sym = node->ms.sym;
256-
al.map = node->ms.map;
257-
al.maps = thread__maps(thread);
256+
al.map = map__get(node->ms.map);
257+
al.maps = maps__get(thread__maps(thread));
258258
al.addr = node->ip;
259259

260260
if (al.map && !al.sym)

0 commit comments

Comments
 (0)