Skip to content

Commit 63fa471

Browse files
davem330acmel
authored andcommitted
perf hists: Catch and handle out-of-date hist entry maps.
When a process exec()'s, all the maps are retired, but we keep the hist entries around which hold references to those outdated maps. If the same library gets mapped in for which we have hist entries, a new map will be created. But when we take a perf entry hit within that map, we'll find the existing hist entry with the older map. This causes symbol translations to be done incorrectly. For example, the perf entry processing will lookup the correct uptodate map entry and use that to calculate the symbol and DSO relative address. But later when we update the histogram we'll translate the address using the outdated map file instead leading to conditions such as out-of-range offsets in symbol__inc_addr_samples(). Therefore, update the map of the hist_entry dynamically at lookup/ creation time. Signed-off-by: David S. Miller <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 8b84a56 commit 63fa471

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tools/perf/util/hist.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,18 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
256256
if (!cmp) {
257257
he->period += period;
258258
++he->nr_events;
259+
260+
/* If the map of an existing hist_entry has
261+
* become out-of-date due to an exec() or
262+
* similar, update it. Otherwise we will
263+
* mis-adjust symbol addresses when computing
264+
* the history counter to increment.
265+
*/
266+
if (he->ms.map != entry->ms.map) {
267+
he->ms.map = entry->ms.map;
268+
if (he->ms.map)
269+
he->ms.map->referenced = true;
270+
}
259271
goto out;
260272
}
261273

0 commit comments

Comments
 (0)