From patchwork Fri Sep 11 04:59:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 53405 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 7A34C22B26 for ; Fri, 11 Sep 2015 04:59:47 +0000 (UTC) Received: by lbbmp1 with SMTP id mp1sf20624527lbb.2 for ; Thu, 10 Sep 2015 21:59:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:content-type:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=K325m/3G8QAsuf6c7Lx9gC/uEaZIng0+86R3HeejtUE=; b=jGVT+//tj2Hf35qFiTx6KBefy3MzgnJhILzoGbbo49Eembtz1Zdmkg6MrzdEV14pDA JUhe/DvyUMU6BXIfk+z86K+665XzSy+JMJxy4QqgqcQD8zMrzIbANgoZ4yFZ6w4TLqgZ jRfMBcXdfnI8pvtrMgLjAdnsTalVrl5FDKHYQOz9aYPyB0bDm/1nvdyN9Vl7zoiVRgV1 VhbfohvHY2hFyA6JCUhHbZbJ0U6oFNMEZq8el8J8cXcv1PMERpz5XfHe7WRpKaxcWJHH AoTH7BbIWK+jRoFooyI+1wZdLf0nWkOR/Mfk1mV1dYHDH/QH9vL9CgYUjaT1ejgJUY2Z WtPA== X-Gm-Message-State: ALoCoQnWIgKaXS4yLa+RlR4k5YN1YZ+RUY//Ekaf9ox8mOKz3fVwTowg4XsOMfFdkZz5SDn840Gd X-Received: by 10.194.118.65 with SMTP id kk1mr10756674wjb.5.1441947586353; Thu, 10 Sep 2015 21:59:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.70 with SMTP id o6ls306499laj.2.gmail; Thu, 10 Sep 2015 21:59:45 -0700 (PDT) X-Received: by 10.112.141.8 with SMTP id rk8mr38764531lbb.87.1441947585939; Thu, 10 Sep 2015 21:59:45 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id w8si12600120lbb.172.2015.09.10.21.59.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2015 21:59:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbcjc2 with SMTP id jc2so33776853lbc.0 for ; Thu, 10 Sep 2015 21:59:45 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr38775498lbc.41.1441947585716; Thu, 10 Sep 2015 21:59:45 -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 w3csp1351655lbq; Thu, 10 Sep 2015 21:59:44 -0700 (PDT) X-Received: by 10.69.2.69 with SMTP id bm5mr90503886pbd.41.1441947584551; Thu, 10 Sep 2015 21:59:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zn4si24235361pbc.212.2015.09.10.21.59.43; Thu, 10 Sep 2015 21:59:44 -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 S1751352AbbIKE7l (ORCPT + 28 others); Fri, 11 Sep 2015 00:59:41 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:16695 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751064AbbIKE7k (ORCPT ); Fri, 11 Sep 2015 00:59:40 -0400 Received: from 172.24.1.51 (EHLO szxeml433-hub.china.huawei.com) ([172.24.1.51]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CSD90752; Fri, 11 Sep 2015 12:59:29 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.235.1; Fri, 11 Sep 2015 12:59:20 +0800 From: Wang Nan To: CC: , , , Wang Nan , Namhyung Kim Subject: [PATCH] perf tools: Fix segfault in 'perf top' Date: Fri, 11 Sep 2015 04:59:11 +0000 Message-ID: <1441947551-48992-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected 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: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 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: , 'perf top' segfaults with following operation: # perf top -e page-faults -p 15173 # 15173 never generate 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 reside 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 checing browser->selection before fetching browser->selection->map and browser->selection->sym. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Namhyung Kim --- tools/perf/ui/browsers/hists.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index e4fd40f..b00fa92 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -2017,7 +2017,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); nr_options += add_socket_opt(browser, &actions[nr_options], &options[nr_options], socket); @@ -2030,7 +2031,10 @@ skip_annotation: nr_options += add_script_opt(browser, &actions[nr_options], &options[nr_options], - NULL, browser->selection->sym); + NULL, + browser->selection ? + browser->selection->sym : + NULL); } nr_options += add_script_opt(browser, &actions[nr_options], &options[nr_options], NULL, NULL);