Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1921514ybt; Thu, 2 Jul 2020 18:07:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOvpWB1EsGj1bOfui7Jy7OBgk8W9l2J5El3iD4MwsEkJxieEuRygzXyopCorOAonk6LeMH X-Received: by 2002:a17:906:8401:: with SMTP id n1mr29721081ejx.479.1593738424582; Thu, 02 Jul 2020 18:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593738424; cv=none; d=google.com; s=arc-20160816; b=Bnb7GwX6ns9tMbgtRtwQjI3fwsa0AUbTWSYwalQRP9raS/5r4z1Rg3k4BCB+htCGDT cp4TmQDyd5B0k5BQnhZu2BdEoGw0wSuIyScgyUR5AUa3+RnBkmuyunPgso0CAr9Evwqo /nY/HKzSu/HyU8EBj0NrNKXvrOG0V0N/ZYqu7RgPXBitAcIhwwGv4Y/yhesHfKjFUtx4 GzhzBDDHoiNP1y7GBnVHRCMCMnMDqE/oN0S42h8cJRnv3b7dyGTKmOJFsecKsamGGr3a MBGbgyVc/RYI502PrHIedv2ybpXkqiSFIIv76OUW4fo8hFo8s7dC2Fwo7D+F9gJ8Tr4i oIOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=mz7ACtsq94ywk67Jxf4274zLsZC49rYM/zj2XUmqVGY=; b=lyQXRyVe4ZxtHpj83m2wcwqu/VHAwyKVQwqZDUeG+Zyl5BBjKADD1p6DqrBTP7VxcR xwi7KdyOh/gOlwK53bG6Eq/K9A+sfHvJrhsF6OntKDjyZpKRPl54TIW+Z0v7Jnr1/8PI XrKK8WqDMV+ZzHZrYs0uO0VzodYiMauNqgwSZBm/ZVC2KULOXmeA29N7wjAOv/JNF7QJ 2c/D+VvRS4812yo2RxPVan6u2fmwtpvpPXErwUIPFuPTCXykbtu98WeFR8ps0y2vAsHU 4ZJgGbfbzXDWw3Mt2co/4lo2J6iOiQs2vIvOZiTDag+fNad4ZPCdtggdBLaxrB10eLgl 2Zig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du22si9166082ejc.330.2020.07.02.18.06.42; Thu, 02 Jul 2020 18:07:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbgGCBE0 (ORCPT + 99 others); Thu, 2 Jul 2020 21:04:26 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6811 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726048AbgGCBEZ (ORCPT ); Thu, 2 Jul 2020 21:04:25 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 4362068708B699E5A6B7; Fri, 3 Jul 2020 09:04:22 +0800 (CST) Received: from [10.174.178.63] (10.174.178.63) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Fri, 3 Jul 2020 09:03:53 +0800 Subject: Re: [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse() To: Arnaldo Carvalho de Melo , Jiri Olsa CC: Namhyung Kim , Mark Rutland , Alexander Shishkin , linux-kernel , Jin Yao , Andi Kleen , References: <20200612094322.39565-1-liwei391@huawei.com> From: "liwei (GF)" Message-ID: <48be67be-9b87-87a1-125a-bb7d0d027a57@huawei.com> Date: Fri, 3 Jul 2020 09:03:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.63] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ping... On 2020/6/12 23:19, Namhyung Kim wrote: > Hello, > > On Fri, Jun 12, 2020 at 6:58 PM Wei Li wrote: >> >> The segmentation fault can be reproduced as following steps: >> 1) Executing perf report in tui. >> 2) Typing '/xxxxx' to filter the symbol to get nothing matched. >> 3) Pressing enter with no entry selected. >> Then it will report a segmentation fault. >> >> It is caused by the lack of check of browser->he_selection when >> accessing it's member res_samples in perf_evsel__hists_browse(). >> >> These processes are meaningful for specified samples, so we can >> skip these when nothing is selected. >> >> Fixes: 4968ac8fb7c3 ("perf report: Implement browsing of individual samples") >> Signed-off-by: Wei Li > > Acked-by: Namhyung Kim > > Thanks > Namhyung > > >> --- >> tools/perf/ui/browsers/hists.c | 17 +++++++++++------ >> 1 file changed, 11 insertions(+), 6 deletions(-) >> >> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c >> index 487e54ef56a9..2101b6b770d8 100644 >> --- a/tools/perf/ui/browsers/hists.c >> +++ b/tools/perf/ui/browsers/hists.c >> @@ -2288,6 +2288,11 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *browser >> return browser->he_selection->thread; >> } >> >> +static struct res_sample *hist_browser__selected_res_sample(struct hist_browser *browser) >> +{ >> + return browser->he_selection ? browser->he_selection->res_samples : NULL; >> +} >> + >> /* Check whether the browser is for 'top' or 'report' */ >> static inline bool is_report_browser(void *timer) >> { >> @@ -3357,16 +3362,16 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events, >> &options[nr_options], NULL, NULL, evsel); >> nr_options += add_res_sample_opt(browser, &actions[nr_options], >> &options[nr_options], >> - hist_browser__selected_entry(browser)->res_samples, >> - evsel, A_NORMAL); >> + hist_browser__selected_res_sample(browser), >> + evsel, A_NORMAL); >> nr_options += add_res_sample_opt(browser, &actions[nr_options], >> &options[nr_options], >> - hist_browser__selected_entry(browser)->res_samples, >> - evsel, A_ASM); >> + hist_browser__selected_res_sample(browser), >> + evsel, A_ASM); >> nr_options += add_res_sample_opt(browser, &actions[nr_options], >> &options[nr_options], >> - hist_browser__selected_entry(browser)->res_samples, >> - evsel, A_SOURCE); >> + hist_browser__selected_res_sample(browser), >> + evsel, A_SOURCE); >> nr_options += add_switch_opt(browser, &actions[nr_options], >> &options[nr_options]); >> skip_scripting: >> -- >> 2.17.1 >>