From patchwork Tue Sep 15 15:08:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 53680 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 8225222DE5 for ; Tue, 15 Sep 2015 15:11:44 +0000 (UTC) Received: by lbot4 with SMTP id t4sf9547741lbo.0 for ; Tue, 15 Sep 2015 08:11:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=gmEljRNqIMVbbDZDFBjoTCDGdduOawF+9OI+1cJgPVk=; b=NT25ktaZRcq6KwkjNZIgkS2tq01kkE2FBCwbigdjPlvyAydrD3Mo5XfI2uigbyUna2 sRBFG2mTmREYgcaAbDYeOPGgAejWiUPtcx9TnBBOLyjxSlmcvn67JKuOyM6h1rBQfcG4 LpD1zGjjFi0XomtYn2z7aqIyT0WveGZj6Nzm7TMXjDP/C9CNaTMUnB7N7p4/I41/sYUz ACER3q/V7XFq67GXuTb9JLbn44djqN0vU/fMg54amwe1bfRvbrlWPlwuIy5rYHwYgGvd HBs+cRASEcETB1Vhv7Uz4+xWBcP/H8A3nKA+a4dW8ap/49n8bAgntrN44ZZVRefvzc2z qfvQ== X-Gm-Message-State: ALoCoQkXLQ+qbQ7hct7KNM3yW0tQBW/q8lt+hdjYzGjv1Stfe8QPMz4WSakjO0yOpIKajou4cL1j X-Received: by 10.152.29.10 with SMTP id f10mr2144635lah.1.1442329903494; Tue, 15 Sep 2015 08:11:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.67 with SMTP id y3ls157890lay.55.gmail; Tue, 15 Sep 2015 08:11:43 -0700 (PDT) X-Received: by 10.152.7.106 with SMTP id i10mr22084160laa.114.1442329903301; Tue, 15 Sep 2015 08:11:43 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id wp2si14230346lbb.136.2015.09.15.08.11.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 08:11:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lanb10 with SMTP id b10so109166301lan.3 for ; Tue, 15 Sep 2015 08:11:43 -0700 (PDT) X-Received: by 10.152.219.34 with SMTP id pl2mr15252362lac.29.1442329903120; Tue, 15 Sep 2015 08:11:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1864369lbq; Tue, 15 Sep 2015 08:11:42 -0700 (PDT) X-Received: by 10.60.140.132 with SMTP id rg4mr19300445oeb.70.1442329901885; Tue, 15 Sep 2015 08:11:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si10092774oeq.43.2015.09.15.08.11.40; Tue, 15 Sep 2015 08:11:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753074AbbIOPLj (ORCPT + 29 others); Tue, 15 Sep 2015 11:11:39 -0400 Received: from casper.infradead.org ([85.118.1.10]:45116 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753373AbbIOPJO (ORCPT ); Tue, 15 Sep 2015 11:09:14 -0400 Received: from 191-247-227-57.3g.claro.net.br ([191.247.227.57] helo=zoo.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zbrr1-0006Uh-UQ; Tue, 15 Sep 2015 15:09:08 +0000 Received: by zoo.infradead.org (Postfix, from userid 1000) id 03D10220150; Tue, 15 Sep 2015 12:09:02 -0300 (BRT) From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Wang Nan , Namhyung Kim , Zefan Li , pi3orama@163.com, Arnaldo Carvalho de Melo Subject: [PATCH 01/15] perf top: Fix segfault pressing -> with no hist entries Date: Tue, 15 Sep 2015 12:08:46 -0300 Message-Id: <1442329740-18042-2-git-send-email-acme@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1442329740-18042-1-git-send-email-acme@kernel.org> References: <1442329740-18042-1-git-send-email-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: acme@kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Wang Nan '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: # ./perf top -e page-faults -p 11400 perf: Segmentation fault -------- backtrace -------- ./perf[0x535428] /lib64/libc.so.6(+0x3545f)[0x7f0dd360745f] ./perf[0x531d46] ./perf(perf_evlist__tui_browse_hists+0x96)[0x5340d6] ./perf[0x44ba2f] /lib64/libpthread.so.0(+0x81d0)[0x7f0dd49dc1d0] /lib64/libc.so.6(clone+0x6c)[0x7f0dd36b90dc] The bug resides in perf_evsel__hists_browse() that, in the above circumstance browser->selection can be NULL, but code after skip_annotation doesn't consider it. This patch fix it by checking browser->selection before fetching browser->selection->map. Signed-off-by: Wang Nan Tested-by: Arnaldo Carvalho de Melo Cc: Namhyung Kim Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1442226235-117265-1-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/hists.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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],