Re: [PATCH] perf stat: Fix segfault for event group in repeat mode

From: Arnaldo Carvalho de Melo
Date: Tue Jul 16 2019 - 14:48:19 EST


Em Mon, Jul 15, 2019 at 04:21:21PM +0200, Jiri Olsa escreveu:
> Numfor Mbiziwo-Tiapo reported segfault on stat of event
> group in repeat mode:
>
> # perf stat -e '{cycles,instructions}' -r 10 ls
>
> It's caused by memory corruption due to not cleaned
> evsel's id array and index, which needs to be rebuilt
> in every stat iteration. Currently the ids index grows,
> while the array (which is also not freed) has the same
> size.
>
> Fixing this by releasing id array and zeroing ids index
> in perf_evsel__close function.
>
> We also need to keep the evsel_list alive for stat
> record (which is disabled in repeat mode).

Thanks, applied.

- Arnaldo