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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fXm_T_REHgCG2ctesmCAu=An6-t-EJAupfd7-et4gGspQ@mail.gmail.com>
Date: Fri, 7 Mar 2025 09:33:30 -0800
From: Ian Rogers <irogers@...gle.com>
To: "Falcon, Thomas" <thomas.falcon@...el.com>
Cc: "namhyung@...nel.org" <namhyung@...nel.org>, "acme@...nel.org" <acme@...nel.org>, 
	"kan.liang@...ux.intel.com" <kan.liang@...ux.intel.com>, "jolsa@...nel.org" <jolsa@...nel.org>, 
	"peterz@...radead.org" <peterz@...radead.org>, "Hunter, Adrian" <adrian.hunter@...el.com>, 
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, 
	"linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>, "mingo@...nel.org" <mingo@...nel.org>
Subject: Re: [PATCH v2 2/2] perf report: Fix memory leaks in the hierarchy mode

On Fri, Mar 7, 2025 at 8:28 AM Falcon, Thomas <thomas.falcon@...el.com> wrote:
>
> On Thu, 2025-03-06 at 22:12 -0800, Namhyung Kim wrote:
> > Ian told me that there are many memory leaks in the hierarchy mode.
> > I
> > can easily reproduce it with the follwing command.
> >
> >   $ make DEBUG=1 EXTRA_CFLAGS=-fsanitize=leak
> >
> >   $ perf record --latency -g -- ./perf test -w thloop
> >
> >   $ perf report -H --stdio
> >   ...
> >   Indirect leak of 168 byte(s) in 21 object(s) allocated from:
> >       #0 0x7f3414c16c65 in malloc
> > ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:75
> >       #1 0x55ed3602346e in map__get util/map.h:189
> >       #2 0x55ed36024cc4 in hist_entry__init util/hist.c:476
> >       #3 0x55ed36025208 in hist_entry__new util/hist.c:588
> >       #4 0x55ed36027c05 in hierarchy_insert_entry util/hist.c:1587
> >       #5 0x55ed36027e2e in hists__hierarchy_insert_entry
> > util/hist.c:1638
> >       #6 0x55ed36027fa4 in hists__collapse_insert_entry
> > util/hist.c:1685
> >       #7 0x55ed360283e8 in hists__collapse_resort util/hist.c:1776
> >       #8 0x55ed35de0323 in report__collapse_hists
> > /home/namhyung/project/linux/tools/perf/builtin-report.c:735
> >       #9 0x55ed35de15b4 in __cmd_report
> > /home/namhyung/project/linux/tools/perf/builtin-report.c:1119
> >       #10 0x55ed35de43dc in cmd_report
> > /home/namhyung/project/linux/tools/perf/builtin-report.c:1867
> >       #11 0x55ed35e66767 in run_builtin
> > /home/namhyung/project/linux/tools/perf/perf.c:351
> >       #12 0x55ed35e66a0e in handle_internal_command
> > /home/namhyung/project/linux/tools/perf/perf.c:404
> >       #13 0x55ed35e66b67 in run_argv
> > /home/namhyung/project/linux/tools/perf/perf.c:448
> >       #14 0x55ed35e66eb0 in main
> > /home/namhyung/project/linux/tools/perf/perf.c:556
> >       #15 0x7f340ac33d67 in __libc_start_call_main
> > ../sysdeps/nptl/libc_start_call_main.h:58
> >   ...
> >
> >   $ perf report -H --stdio 2>&1 | grep -c '^Indirect leak'
> >   93
> >
> > I found that hist_entry__delete() missed to release child entries in
> > the
> > hierarchy tree (hroot_{in,out}).  It needs to iterate the child
> > entries
> > and call hist_entry__delete() recursively.
> >
> > After this change:
> >
> >   $ perf report -H --stdio 2>&1 | grep -c '^Indirect leak'
> >   0
> >
> > Reported-by: Ian Rogers <irogers@...gle.com>
> > Signed-off-by: Namhyung Kim <namhyung@...nel.org>
>
> Tested on an Arrow Lake system.
>
> Tested-by Thomas Falcon <thomas.falcon@...el.com>

Reviewed-by: Ian Rogers <irogers@...gle.com>

Thanks!
Ian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ