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

From: Arnaldo Carvalho de Melo
Date: Wed Oct 19 2011 - 15:20:23 EST


Em Wed, Oct 19, 2011 at 12:44:48PM -0600, David Ahern escreveu:
> On 10/19/2011 12:38 PM, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Oct 19, 2011 at 12:23:18PM -0600, David Ahern escreveu:
> >> Hitting an annotate case where src is not set and
> >> perf-top crashes.

> > How did you got there?
>
> I was starting perf top, selecting a symbol and pressing 'a'. In the
> crash case it was the perf command itself.

Humm, looks like a race, the old 'perf top --tui' had this:

static void perf_top_browser__annotate(struct perf_top_browser *browser)
{
struct sym_entry *syme = browser->selection;
struct symbol *sym = sym_entry__symbol(syme);
struct annotation *notes = symbol__annotation(sym);
struct perf_top *top = browser->b.priv;

if (notes->src != NULL)
goto do_annotation;

pthread_mutex_lock(&notes->lock);

top->sym_filter_entry = NULL;

if (symbol__alloc_hist(sym, top->evlist->nr_entries) < 0) {
pr_err("Not enough memory for annotating '%s' symbol!\n",
sym->name);
pthread_mutex_unlock(&notes->lock);
return;
}

top->sym_filter_entry = syme;

pthread_mutex_unlock(&notes->lock);
do_annotation:
symbol__tui_annotate(sym, syme->map, 0, top->delay_secs * 1000);
}


Which is not even completely right, the notes->src should happen inside
the lock, like parse_source in the --stdio...

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?

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