Re: [PATCH v1 3/4] perf trace: Add missed freeing of ordered events and thread

From: Ian Rogers
Date: Tue Jun 17 2025 - 17:34:21 EST


On Tue, Jun 17, 2025 at 2:30 PM Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
>
> On Mon, Jun 16, 2025 at 01:27:04PM -0300, Arnaldo Carvalho de Melo wrote:
> > On Fri, Jun 13, 2025 at 09:16:26PM -0700, Howard Chu wrote:
> > > TL;DR: (definitely lost: 5,248 bytes in 17 blocks, 3,586 bytes in 12
> > > blocks) -> (definitely lost: 4,992 bytes in 16 blocks, indirectly
> > > lost: 0 bytes in 0 blocks), the leak of thread__new() is fixed.
> > >
> > > Thank you so much for fixing this.
> > >
> > > On Fri, Jun 13, 2025 at 5:41 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
> > > >
> > > > Caught by leak sanitizer running "perf trace BTF general tests".
> > > >
> > > > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> > >
> > > Acked-by: Howard Chu <howardchu95@xxxxxxxxx>
> >
> > Small enough, applied to perf-tools.
>
> root@number:~# perf trace -e *sleep ls
> anaconda-ks.cfg bin bla commands dtel firefly logind.conf perf-install.txt python
> perf: Segmentation fault
> Obtained 11 stack frames.
> perf() [0x5c595e]
> perf() [0x5c59f9]
> /lib64/libc.so.6(+0x19c30) [0x7fd43ce27c30]
> perf() [0x5dc497]
> perf() [0x492d54]
> perf() [0x49860e]
> perf() [0x49890e]
> perf() [0x413413]
> /lib64/libc.so.6(+0x35f5) [0x7fd43ce115f5]
> /lib64/libc.so.6(__libc_start_main+0x88) [0x7fd43ce116a8]
> perf() [0x413a45]
> Segmentation fault (core dumped)
> root@number:~#

Thanks, I'll take a look to see if I can spot what's broken. Seeing
this stack trace makes me remember we haven't landed:
https://lore.kernel.org/lkml/20250611221521.722045-1-irogers@xxxxxxxxxx/

Ian

> ⬢ [acme@toolbx perf-tools]$ git bisect good
> e340815ea559052d8d590a145bab7d7105608e7d is the first bad commit
> commit e340815ea559052d8d590a145bab7d7105608e7d
> Author: Ian Rogers <irogers@xxxxxxxxxx>
> Date: Fri Jun 13 17:41:06 2025 -0700
>
> perf trace: Add missed freeing of ordered events and thread
>
> Caught by leak sanitizer running "perf trace BTF general tests".
>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> Acked-by: Howard Chu <howardchu95@xxxxxxxxx>
> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
> Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Jiapeng Chong <jiapeng.chong@xxxxxxxxxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
> Cc: Mark Rutland <mark.rutland@xxxxxxx>
> Cc: Michael Petlan <mpetlan@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
> Link: https://lore.kernel.org/r/20250614004108.1650988-3-irogers@xxxxxxxxxx
> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
>
> tools/perf/builtin-trace.c | 2 ++
> 1 file changed, 2 insertions(+)
> ⬢ [acme@toolbx perf-tools]$
>
> Removing it:
>
> root@number:~# perf trace -e *sleep sleep 1
> 0.000 (1000.057 ms): sleep/2693449 clock_nanosleep(rqtp: { .tv_sec: 1, .tv_nsec: 0 }, rmtp: 0x7fffedc43ab0) = 0
> root@number:~#
>
> - Arnaldo