From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753268AbbHVGwR (ORCPT ); Sat, 22 Aug 2015 02:52:17 -0400 Received: from terminus.zytor.com ([198.137.202.10]:60066 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752781AbbHVGv5 (ORCPT ); Sat, 22 Aug 2015 02:51:57 -0400 Date: Fri, 21 Aug 2015 23:51:38 -0700 From: tip-bot for Adrian Hunter Message-ID: Cc: acme@redhat.com, adrian.hunter@intel.com, jolsa@redhat.com, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org Reply-To: adrian.hunter@intel.com, acme@redhat.com, jolsa@redhat.com, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1440059205-1765-1-git-send-email-adrian.hunter@intel.com> References: <1440059205-1765-1-git-send-email-adrian.hunter@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf script: Fix segfault using --show-mmap-events Git-Commit-ID: 05169df5561363ff04ac04d6aad0be3b45c26ac1 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 05169df5561363ff04ac04d6aad0be3b45c26ac1 Gitweb: http://git.kernel.org/tip/05169df5561363ff04ac04d6aad0be3b45c26ac1 Author: Adrian Hunter AuthorDate: Thu, 20 Aug 2015 11:26:45 +0300 Committer: Arnaldo Carvalho de Melo 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 Fixes: 06b234ec26fd ("perf script: Don't assume evsel position of tracking events") Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1440059205-1765-1-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- 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);