Skip to content

Commit 33941db

Browse files
captain5050namhyung
authored andcommitted
perf unwind: Fix map reference counts
The result of thread__find_map is the map in the passed in addr_location. Calling addr_location__exit puts that map and so copies need to do a map__get. Add in the corresponding map__puts. v2. Add missing map__put when dso is missing. Signed-off-by: Ian Rogers <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Ivan Babrou <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent e4ef3ef commit 33941db

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tools/perf/util/unwind-libunwind-local.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ static struct map *find_map(unw_word_t ip, struct unwind_info *ui)
419419
struct map *ret;
420420

421421
addr_location__init(&al);
422-
ret = thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al);
422+
thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al);
423+
ret = map__get(al.map);
423424
addr_location__exit(&al);
424425
return ret;
425426
}
@@ -440,8 +441,10 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
440441
return -EINVAL;
441442

442443
dso = map__dso(map);
443-
if (!dso)
444+
if (!dso) {
445+
map__put(map);
444446
return -EINVAL;
447+
}
445448

446449
pr_debug("unwind: find_proc_info dso %s\n", dso->name);
447450

@@ -476,11 +479,11 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
476479

477480
memset(&di, 0, sizeof(di));
478481
if (dwarf_find_debug_frame(0, &di, ip, base, symfile, start, map__end(map)))
479-
return dwarf_search_unwind_table(as, ip, &di, pi,
480-
need_unwind_info, arg);
482+
ret = dwarf_search_unwind_table(as, ip, &di, pi,
483+
need_unwind_info, arg);
481484
}
482485
#endif
483-
486+
map__put(map);
484487
return ret;
485488
}
486489

@@ -534,12 +537,14 @@ static int access_dso_mem(struct unwind_info *ui, unw_word_t addr,
534537

535538
dso = map__dso(map);
536539

537-
if (!dso)
540+
if (!dso) {
541+
map__put(map);
538542
return -1;
543+
}
539544

540545
size = dso__data_read_addr(dso, map, ui->machine,
541546
addr, (u8 *) data, sizeof(*data));
542-
547+
map__put(map);
543548
return !(size == sizeof(*data));
544549
}
545550

0 commit comments

Comments
 (0)