Re: [PATCH] perf top: fix crash on annotate request

From: Arnaldo Carvalho de Melo
Date: Thu Oct 20 2011 - 09:00:46 EST


Em Wed, Oct 19, 2011 at 04:12:32PM -0600, David Ahern escreveu:
>
>
> Getting another crash with the default sym sorting -- the addr is much
> less than the start of the sym so the offset goes negative:
>
> (gdb) bt
> #0 0x0000000000429de3 in symbol__inc_addr_samples (sym=0x8f0f90,
> map=0x8aae00, evidx=0,
> addr=329985) at util/annotate.c:73
> #1 0x000000000041b073 in record_precise_ip (he=0x8a2a10, counter=0,
> ip=329985)
> at builtin-top.c:221
> #2 0x000000000041c821 in perf_event__process_sample (event=0x7fffefbc74c8,
> sample=0x7fffffffe1b0, session=0x89a140) at builtin-top.c:801
> #3 0x000000000041c8d4 in perf_session__mmap_read_idx (self=0x89a140,
> idx=12)
> at builtin-top.c:821
> #4 0x000000000041c95b in perf_session__mmap_read (self=0x89a140) at
> builtin-top.c:832
> #5 0x000000000041cdf1 in __cmd_top () at builtin-top.c:960
> #6 0x000000000041d585 in cmd_top (argc=0, argv=0x7fffffffe590, prefix=0x0)
> at builtin-top.c:1252
> #7 0x00000000004077b9 in run_builtin (p=0x75fb68, argc=2,
> argv=0x7fffffffe590) at perf.c:286
> #8 0x00000000004079bb in handle_internal_command (argc=2,
> argv=0x7fffffffe590) at perf.c:358
> #9 0x0000000000407b07 in run_argv (argcp=0x7fffffffe47c,
> argv=0x7fffffffe470) at perf.c:402
> #10 0x0000000000407dee in main (argc=2, argv=0x7fffffffe590) at perf.c:512
>
>
> The following fixes the crash. If it seems reasonable I'll add to the
> other one:
>
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index bc8f477..f1f20b5 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -63,6 +63,8 @@ int symbol__inc_addr_samples(struct symbol *sym,
> struct map *map,
> return -ENOMEM;
>
> pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map,
> addr));
> + if (addr < sym->start)
> + return 0;

But this one seems like papering over some real problem, i.e. why would
we ask to bump an address that is _outside_ this symbol range? I.e.:

In record_precise_ip() this part must be wrong:

ip = he->ms.map->map_ip(he->ms.map, ip);
symbol__inc_addr_samples(sym, he->ms.map, counter, ip)

I.e. the map_ip for this method is messing up things, what symbol is
this? I.e. please provide:

p *sym
p *map

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/