lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH0uvojjfOcoZmxPL+bG5NEid8xcAVth7UxOUc=aYjgF5nqs2A@mail.gmail.com>
Date: Fri, 13 Jun 2025 21:16:26 -0700
From: Howard Chu <howardchu95@...il.com>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
	Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>, 
	Mark Rutland <mark.rutland@....com>, 
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>, 
	Adrian Hunter <adrian.hunter@...el.com>, Kan Liang <kan.liang@...ux.intel.com>, 
	Michael Petlan <mpetlan@...hat.com>, Andi Kleen <ak@...ux.intel.com>, 
	Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>, Tiezhu Yang <yangtiezhu@...ngson.cn>, 
	linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 3/4] perf trace: Add missed freeing of ordered events
 and thread

Hello Ian,

before:
~~~
$ sudo valgrind --leak-check=full /tmp/perf/perf trace --sort-events
-e openat* --max-events=1 -- echo 1
==248676== Memcheck, a memory error detector
==248676== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==248676== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==248676== Command: /tmp/perf/perf trace --sort-events -e openat*
--max-events=1 -- echo 1
...
==248676== 3,842 (256 direct, 3,586 indirect) bytes in 1 blocks are
definitely lost in loss record 2,773 of 2,808
==248676==    at 0x484FBE3: calloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==248676==    by 0x3634E1: thread__new (in /tmp/perf/perf)
==248676==    by 0x363BBE: threads__findnew (in /tmp/perf/perf)
==248676==    by 0x34DAB6: machine__findnew_thread (in /tmp/perf/perf)
==248676==    by 0x34E655: machine__process_comm_event (in /tmp/perf/perf)
==248676==    by 0x2071B1: __trace__deliver_event.isra.0 (in /tmp/perf/perf)
==248676==    by 0x2072EA: ordered_events__deliver_event (in /tmp/perf/perf)
==248676==    by 0x3608D2: __ordered_events__flush (in /tmp/perf/perf)
==248676==    by 0x20CB19: trace__run (in /tmp/perf/perf)
==248676==    by 0x21183D: cmd_trace (in /tmp/perf/perf)
==248676==    by 0x215E6F: run_builtin (in /tmp/perf/perf)
==248676==    by 0x21618A: handle_internal_command (in /tmp/perf/perf)
...
==248676== 4,992 bytes in 16 blocks are definitely lost in loss record
2,776 of 2,808
==248676==    at 0x484FE10: realloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==248676==    by 0x57CCBCD: __vasprintf_internal (vasprintf.c:123)
==248676==    by 0x5878152: __asprintf_chk (asprintf_chk.c:34)
==248676==    by 0x31ED18: parse_events_formats_error_string (in /tmp/perf/perf)
==248676==    by 0x36DCA7: perf_pmu__config_terms (in /tmp/perf/perf)
==248676==    by 0x370CD8: perf_pmu__name_from_config (in /tmp/perf/perf)
==248676==    by 0x43216A: arch_is_topdown_metrics (in /tmp/perf/perf)
==248676==    by 0x432AD7: arch_evsel__must_be_in_group (in /tmp/perf/perf)
==248676==    by 0x31C657: __parse_events (in /tmp/perf/perf)
==248676==    by 0x31CD1E: parse_event (in /tmp/perf/perf)
==248676==    by 0x3A2D76: perf_can_comm_exec (in /tmp/perf/perf)
==248676==    by 0x3A374F: evlist__config (in /tmp/perf/perf)
...
==248676==
==248676== LEAK SUMMARY:
==248676==    definitely lost: 5,248 bytes in 17 blocks
==248676==    indirectly lost: 3,586 bytes in 12 blocks
==248676==      possibly lost: 311,943 bytes in 5,292 blocks
==248676==    still reachable: 740,220 bytes in 21,186 blocks
==248676==         suppressed: 0 bytes in 0 blocks
==248676== Reachable blocks (those to which a pointer was found) are not shown.
==248676== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==248676==
==248676== For lists of detected and suppressed errors, rerun with: -s
==248676== ERROR SUMMARY: 56 errors from 56 contexts (suppressed: 0 from 0)
~~~

after:
~~~
$ sudo valgrind --leak-check=full /tmp/perf/perf trace --sort-events
-e openat* --max-events=1 -- echo 1
==245044== Memcheck, a memory error detector
==245044== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==245044== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==245044== Command: /tmp/perf/perf trace --sort-events -e openat*
--max-events=1 -- echo 1
==245044==
--245044-- WARNING: unhandled eBPF command 36
--245044-- WARNING: unhandled eBPF command 28
--245044-- WARNING: unhandled eBPF command 28
--245044-- WARNING: unhandled eBPF command 28
--245044-- WARNING: unhandled eBPF command 28
--245044-- WARNING: unhandled eBPF command 28
libbpf: failed to read kernel BTF from '/sys/kernel/btf/vmlinux': -ENODEV
libbpf: failed to read kernel BTF from '/sys/kernel/btf/vmlinux': -ENODEV
libbpf: failed to read kernel BTF from '/sys/kernel/btf/vmlinux': -ENODEV
...
==245044== 4,992 bytes in 16 blocks are definitely lost in loss record
2,763 of 2,794
==245044==    at 0x484FE10: realloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==245044==    by 0x57CCBCD: __vasprintf_internal (vasprintf.c:123)
==245044==    by 0x5878152: __asprintf_chk (asprintf_chk.c:34)
==245044==    by 0x31ED98: parse_events_formats_error_string (in /tmp/perf/perf)
==245044==    by 0x36DD27: perf_pmu__config_terms (in /tmp/perf/perf)
==245044==    by 0x370D58: perf_pmu__name_from_config (in /tmp/perf/perf)
==245044==    by 0x4321EA: arch_is_topdown_metrics (in /tmp/perf/perf)
==245044==    by 0x432B57: arch_evsel__must_be_in_group (in /tmp/perf/perf)
==245044==    by 0x31C6D7: __parse_events (in /tmp/perf/perf)
==245044==    by 0x31CD9E: parse_event (in /tmp/perf/perf)
==245044==    by 0x3A2DF6: perf_can_comm_exec (in /tmp/perf/perf)
==245044==    by 0x3A37CF: evlist__config (in /tmp/perf/perf)
...
==245044== LEAK SUMMARY:
==245044==    definitely lost: 4,992 bytes in 16 blocks
==245044==    indirectly lost: 0 bytes in 0 blocks
==245044==      possibly lost: 245,988 bytes in 5,288 blocks
==245044==    still reachable: 740,211 bytes in 21,185 blocks
==245044==         suppressed: 0 bytes in 0 blocks
==245044== Reachable blocks (those to which a pointer was found) are not shown.
==245044== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==245044==
==245044== For lists of detected and suppressed errors, rerun with: -s
==245044== ERROR SUMMARY: 51 errors from 51 contexts (suppressed: 0 from 0)
~~~

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@...gle.com> wrote:
>
> Caught by leak sanitizer running "perf trace BTF general tests".
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>

Acked-by: Howard Chu <howardchu95@...il.com>

Thanks,
Howard

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ