Re: [PATCH] perf, tools: Fix crash in 'perf trace'

From: Sukadev Bhattiprolu
Date: Fri Jun 12 2015 - 21:58:36 EST


Arnaldo Carvalho de Melo [acme@xxxxxxxxxx] wrote:
| Em Thu, Jun 11, 2015 at 11:00:04PM -0700, Sukadev Bhattiprolu escreveu:
| > >From 6669ed960a3ee4f9a02790f60b6a73ffc82fd6de Mon Sep 17 00:00:00 2001
| > From: Sukadev Bhattiprolu <sukadev@xxxxxxxxxxxxxxxxxx>
| > Date: Fri, 12 Jun 2015 01:28:36 -0400
| > Subject: [PATCH] perf, tools: Fix crash in perf trace
| >
| > I get following crash on multiple systems and across several releases
| > (at least since v3.18).
|
| Trying it in perf/core I get:
|

Ah, I should have based on perf/core.

| util/evlist.c: In function âperf_evlist__mmap_readâ:
| util/evlist.c:645:6: error: wrong type argument to unary exclamation
| mark
| if (!md->refcnt)
|
| Trying after changing it to !atomic_read(&md->refcnt)
|
| And it fixes the segfault that I reproduced, but this still looks
| strange, i.e. if it hit zero, then it should not have been used at this
| point anymore... Will look at it again in the weekend. :-\

I think its a small window - where application has started exiting,
and set the PERF_EVENT_STATE_EXIT flag, but has not exited "enough"
to issue a SIGCHLD. (Also we check the 'done' flag once - we could
get SIGCHLD just after the check?)

Anyway, the poll() in this window returns with POLLHUP and we unmap
the region.

Sukadev

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