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

From: Arnaldo Carvalho de Melo
Date: Thu Oct 20 2011 - 08:51:52 EST


Em Wed, Oct 19, 2011 at 03:39:30PM -0600, David Ahern escreveu:
> On 10/19/2011 01:20 PM, Arnaldo Carvalho de Melo wrote:
> > Can you check if that is the problem? I.e. take notes->lock, check if
> > ->src is NULL, if so call symbol__alloc_hist, etc?
> >
>
> Reproduced it on a lab box. This fixes the segfault:
>
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index bc8f477..6bd501a 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -253,6 +253,17 @@ static int symbol__parse_objdump_line(struct symbol
> *sym, struct map *map,
> free(line);
> return -1;
> }
> +
> + pthread_mutex_lock(&notes->lock);
> + if (notes->src == NULL &&
> + symbol__alloc_hist(sym, 1) < 0) {
> + pthread_mutex_unlock(&notes->lock);
> + ui__warning("Not enough memory for annotating '%s' symbol!\n",
> + sym->name);
> + return -1;
> + }
> + pthread_mutex_unlock(&notes->lock);
> +
> objdump__add_line(&notes->src->source, objdump_line);
>
> return 0;
>
> Should I plumb nr_events down versus assuming its 1?

better to plumb it properly, i.e. at some point where you have access to
evlist to get its ->nr_entries so that we properly support multiple
events.

- 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/