Re: [PATCH] perf c2c report: Fix crash for empty browser
From: Arnaldo Carvalho de Melo
Date: Thu Jul 26 2018 - 15:30:52 EST
Em Tue, Jul 24, 2018 at 08:20:08AM +0200, Jiri Olsa escreveu:
> Do not try to display entry details if there's
> not any. Currently this ends up in crash:
> $ perf c2c report
> perf: Segmentation fault
How to replicate this?
I tried:
$ perf record sleep 1
$ perf c2c report
But it didn't segfault
> Reported-by: rodia@xxxxxxxxxxxxx
> Link: http://lkml.kernel.org/n/tip-3d7qjz9x49ay9ncerfordcv3@xxxxxxxxxxxxxx
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> tools/perf/builtin-c2c.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index f2ea85ee573f..f3aa9d02a5ab 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c
> @@ -2349,6 +2349,9 @@ static int perf_c2c__browse_cacheline(struct hist_entry *he)
> " s Toggle full length of symbol and source line columns \n"
> " q Return back to cacheline list \n";
>
> + if (!he)
> + return 0;
> +
> /* Display compact version first. */
> c2c.symbol_full = false;
>
> --
> 2.17.1