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

From: David Ahern
Date: Wed Oct 19 2011 - 17:39:35 EST




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