* [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse()
@ 2020-06-12 9:43 Wei Li
2020-06-12 15:19 ` Namhyung Kim
2020-07-03 11:10 ` Jiri Olsa
0 siblings, 2 replies; 5+ messages in thread
From: Wei Li @ 2020-06-12 9:43 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim
Cc: linux-kernel, Jin Yao, Andi Kleen, guohanjun
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 <liwei391@huawei.com>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse()
2020-06-12 9:43 [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse() Wei Li
@ 2020-06-12 15:19 ` Namhyung Kim
2020-07-03 1:03 ` liwei (GF)
2020-07-03 11:10 ` Jiri Olsa
1 sibling, 1 reply; 5+ messages in thread
From: Namhyung Kim @ 2020-06-12 15:19 UTC (permalink / raw)
To: Wei Li
Cc: Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Jiri Olsa, linux-kernel, Jin Yao, Andi Kleen, guohanjun
Hello,
On Fri, Jun 12, 2020 at 6:58 PM Wei Li <liwei391@huawei.com> 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 <liwei391@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse()
2020-06-12 15:19 ` Namhyung Kim
@ 2020-07-03 1:03 ` liwei (GF)
2020-07-03 11:59 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 5+ messages in thread
From: liwei (GF) @ 2020-07-03 1:03 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Jiri Olsa
Cc: Namhyung Kim, Mark Rutland, Alexander Shishkin, linux-kernel,
Jin Yao, Andi Kleen, guohanjun
Ping...
On 2020/6/12 23:19, Namhyung Kim wrote:
> Hello,
>
> On Fri, Jun 12, 2020 at 6:58 PM Wei Li <liwei391@huawei.com> 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 <liwei391@huawei.com>
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
>
> 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
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse()
2020-07-03 1:03 ` liwei (GF)
@ 2020-07-03 11:59 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-07-03 11:59 UTC (permalink / raw)
To: liwei (GF)
Cc: Jiri Olsa, Namhyung Kim, Mark Rutland, Alexander Shishkin,
linux-kernel, Jin Yao, Andi Kleen, guohanjun
Em Fri, Jul 03, 2020 at 09:03:53AM +0800, liwei (GF) escreveu:
> Ping...
Thanks, applied and tested, added the Acked-by Jiri and Namhyung
provided,
- Arnaldo
> On 2020/6/12 23:19, Namhyung Kim wrote:
> > Hello,
> >
> > On Fri, Jun 12, 2020 at 6:58 PM Wei Li <liwei391@huawei.com> 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 <liwei391@huawei.com>
> >
> > Acked-by: Namhyung Kim <namhyung@kernel.org>
> >
> > 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
> >>
--
- Arnaldo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse()
2020-06-12 9:43 [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse() Wei Li
2020-06-12 15:19 ` Namhyung Kim
@ 2020-07-03 11:10 ` Jiri Olsa
1 sibling, 0 replies; 5+ messages in thread
From: Jiri Olsa @ 2020-07-03 11:10 UTC (permalink / raw)
To: Wei Li
Cc: Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Namhyung Kim, linux-kernel, Jin Yao, Andi Kleen, guohanjun
On Fri, Jun 12, 2020 at 05:43:22PM +0800, 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 <liwei391@huawei.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
thanks,
jirka
> ---
> 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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-03 11:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12 9:43 [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse() Wei Li
2020-06-12 15:19 ` Namhyung Kim
2020-07-03 1:03 ` liwei (GF)
2020-07-03 11:59 ` Arnaldo Carvalho de Melo
2020-07-03 11:10 ` Jiri Olsa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.