From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751601AbbINSND (ORCPT ); Mon, 14 Sep 2015 14:13:03 -0400 Received: from mail.kernel.org ([198.145.29.136]:44875 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751210AbbINSNB (ORCPT ); Mon, 14 Sep 2015 14:13:01 -0400 Date: Mon, 14 Sep 2015 15:12:56 -0300 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: namhyung@kernel.org, linux-kernel@vger.kernel.org, lizefan@huawei.com, pi3orama@163.com Subject: Re: [PATCH v2] perf tools: Fix segfault in 'perf top' Message-ID: <20150914181256.GD5250@kernel.org> References: <20150911162207.GD3447@danjae.kornet> <1442226235-117265-1-git-send-email-wangnan0@huawei.com> <20150914180714.GC5250@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150914180714.GC5250@kernel.org> 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 Mon, Sep 14, 2015 at 03:07:14PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Mon, Sep 14, 2015 at 10:23:55AM +0000, Wang Nan escreveu: > > 'perf top' segfaults with following operation: > > > > # perf top -e page-faults -p 11400 # 11400 never generates page-fault > > > > Then on the resulting empty interface, press right key: > > So, this happens in perf/urgent, so we need to apply it there first, > which this patch doesn't. > > I am fixing it up this time, thanks for the patch! For reference, below is the resulting patch, pushed to acme/perf/urgent, now checking if there are more patches to go together with this one... - Arnaldo diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index cf86f2d3a5e7..c04c60d4863c 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -1968,7 +1968,8 @@ skip_annotation: &options[nr_options], dso); nr_options += add_map_opt(browser, &actions[nr_options], &options[nr_options], - browser->selection->map); + browser->selection ? + browser->selection->map : NULL); /* perf script support */ if (browser->he_selection) { @@ -1976,6 +1977,15 @@ skip_annotation: &actions[nr_options], &options[nr_options], thread, NULL); + /* + * Note that browser->selection != NULL + * when browser->he_selection is not NULL, + * so we don't need to check browser->selection + * before fetching browser->selection->sym like what + * we do before fetching browser->selection->map. + * + * See hist_browser__show_entry. + */ nr_options += add_script_opt(browser, &actions[nr_options], &options[nr_options],