Re: [PATCH 1/4] perf record: Fix a segfault in record__read_lost_samples()

From: Leo Yan
Date: Sat Sep 24 2022 - 21:12:51 EST


On Fri, Sep 23, 2022 at 10:31:39AM -0700, Namhyung Kim wrote:
> When it fails to open events record__open() returns without setting the
> session->evlist. Then it gets a segfault in the function trying to read
> lost sample counts. You can easily reproduce it as a normal user like:
>
> $ perf record -p 1 true
> ...
> perf: Segmentation fault
> ...
>
> Skip the function if it has no evlist. And add more protection for evsels
> which are not properly initialized.
>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>

Tested-by: Leo Yan <leo.yan@xxxxxxxxxx>