From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752382AbbHTTYe (ORCPT ); Thu, 20 Aug 2015 15:24:34 -0400 Received: from mail.kernel.org ([198.145.29.136]:55585 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbbHTTYd (ORCPT ); Thu, 20 Aug 2015 15:24:33 -0400 Date: Thu, 20 Aug 2015 16:24:25 -0300 From: Arnaldo Carvalho de Melo To: Adrian Hunter Cc: linux-kernel@vger.kernel.org, Jiri Olsa Subject: Re: [PATCH] perf script: Fix segfault using --show-mmap-events Message-ID: <20150820192425.GB3154@kernel.org> References: <1440059205-1765-1-git-send-email-adrian.hunter@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1440059205-1765-1-git-send-email-adrian.hunter@intel.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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