Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1211240

[PATCH 1/9] perf script: Fix segfault using --show-mmap-events

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 1/9] perf script: Fix segfault using --show-mmap-events
Date 2015-08-21 18:20 +0200
Message-ID <pZXcU-kI-77@gated-at.bofh.it> (permalink)
References <pZXcR-kI-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Adrian Hunter <adrian.hunter@intel.com>

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 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);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 0/9] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-21 18:20 +0200
  [PATCH 4/9] tools lib traceevent: Add checks for returned EVENT_ERROR type Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-21 18:20 +0200
  [PATCH 6/9] perf tools: Put itrace options into an asciidoc include Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-21 18:20 +0200
  [PATCH 3/9] perf tools: Fix Intel PT timestamp handling Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-21 18:20 +0200
  [PATCH 8/9] perf tools: Initialize reference counts in map__clone() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-21 18:20 +0200
  [PATCH 1/9] perf script: Fix segfault using --show-mmap-events Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-21 18:20 +0200
  Re: [GIT PULL 0/9] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2015-08-22 08:50 +0200

csiph-web