* [PATCH] perf script: Fix segfault using --show-mmap-events
@ 2015-08-20 8:26 Adrian Hunter
2015-08-20 19:24 ` Arnaldo Carvalho de Melo
2015-08-22 6:51 ` [tip:perf/core] " tip-bot for Adrian Hunter
0 siblings, 2 replies; 3+ messages in thread
From: Adrian Hunter @ 2015-08-20 8:26 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-kernel, Jiri Olsa
Patch "perf script: Don't assume evsel position of tracking events"
changed 'perf script' to use 'perf_evlist__id2evsel()'. That results
in a segfault if there is more than 1 event and there are
synthesized mmap events e.g.
$ perf record -e cycles,instructions -p$$ sleep 1
$ perf script --show-mmap-events
Segmentation fault (core dumped)
That happens because these synthesized events have an 'id' of zero
which does not match any 'evsel'.
Currently, these synthesized events use the sample type of the first
evsel.
Change 'perf_evlist__id2evsel()' to reflect that which also makes
it consistent with 'perf_evlist__event2evsel()'.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/evlist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 373f65b02545..e9a5d432902c 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -573,7 +573,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
{
struct perf_sample_id *sid;
- if (evlist->nr_entries == 1)
+ if (evlist->nr_entries == 1 || !id)
return perf_evlist__first(evlist);
sid = perf_evlist__id2sid(evlist, id);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf script: Fix segfault using --show-mmap-events
2015-08-20 8:26 [PATCH] perf script: Fix segfault using --show-mmap-events Adrian Hunter
@ 2015-08-20 19:24 ` Arnaldo Carvalho de Melo
2015-08-22 6:51 ` [tip:perf/core] " tip-bot for Adrian Hunter
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-08-20 19:24 UTC (permalink / raw)
To: Adrian Hunter; +Cc: linux-kernel, Jiri Olsa
Em Thu, Aug 20, 2015 at 11:26:45AM +0300, Adrian Hunter escreveu:
> Patch "perf script: Don't assume evsel position of tracking events"
> changed 'perf script' to use 'perf_evlist__id2evsel()'. That results
> in a segfault if there is more than 1 event and there are
> synthesized mmap events e.g.
>
> $ perf record -e cycles,instructions -p$$ sleep 1
> $ perf script --show-mmap-events
> Segmentation fault (core dumped)
Please next time tell what branch this affects, otherwise I'll have to
try it on perf/urgent, notice that the problem is not there, then try it
again on perf/core, where it is, to then apply...
Applied to perf/core.
Thanks,
- Arnaldo
> That happens because these synthesized events have an 'id' of zero
> which does not match any 'evsel'.
>
> Currently, these synthesized events use the sample type of the first
> evsel.
>
> Change 'perf_evlist__id2evsel()' to reflect that which also makes
> it consistent with 'perf_evlist__event2evsel()'.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> tools/perf/util/evlist.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 373f65b02545..e9a5d432902c 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -573,7 +573,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
> {
> struct perf_sample_id *sid;
>
> - if (evlist->nr_entries == 1)
> + if (evlist->nr_entries == 1 || !id)
> return perf_evlist__first(evlist);
>
> sid = perf_evlist__id2sid(evlist, id);
> --
> 1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [tip:perf/core] perf script: Fix segfault using --show-mmap-events
2015-08-20 8:26 [PATCH] perf script: Fix segfault using --show-mmap-events Adrian Hunter
2015-08-20 19:24 ` Arnaldo Carvalho de Melo
@ 2015-08-22 6:51 ` tip-bot for Adrian Hunter
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Adrian Hunter @ 2015-08-22 6:51 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, adrian.hunter, jolsa, tglx, hpa, mingo, linux-kernel
Commit-ID: 05169df5561363ff04ac04d6aad0be3b45c26ac1
Gitweb: http://git.kernel.org/tip/05169df5561363ff04ac04d6aad0be3b45c26ac1
Author: Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Thu, 20 Aug 2015 11:26:45 +0300
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 21 Aug 2015 10:29:22 -0300
perf script: Fix segfault using --show-mmap-events
Patch "perf script: Don't assume evsel position of tracking events"
changed 'perf script' to use 'perf_evlist__id2evsel()'. That results
in a segfault if there is more than 1 event and there are
synthesized mmap events e.g.
$ perf record -e cycles,instructions -p$$ sleep 1
$ perf script --show-mmap-events
Segmentation fault (core dumped)
That happens because these synthesized events have an 'id' of zero
which does not match any 'evsel'.
Currently, these synthesized events use the sample type of the first
evsel.
Change 'perf_evlist__id2evsel()' to reflect that which also makes
it consistent with 'perf_evlist__event2evsel()'.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: 06b234ec26fd ("perf script: Don't assume evsel position of tracking events")
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1440059205-1765-1-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/evlist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 373f65b..e9a5d43 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -573,7 +573,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
{
struct perf_sample_id *sid;
- if (evlist->nr_entries == 1)
+ if (evlist->nr_entries == 1 || !id)
return perf_evlist__first(evlist);
sid = perf_evlist__id2sid(evlist, id);
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-22 6:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-20 8:26 [PATCH] perf script: Fix segfault using --show-mmap-events Adrian Hunter
2015-08-20 19:24 ` Arnaldo Carvalho de Melo
2015-08-22 6:51 ` [tip:perf/core] " tip-bot for Adrian Hunter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox