All of lore.kernel.org
 help / color / mirror / Atom feed
From: Riccardo Mancini <rickyman7@gmail.com>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	Ian Rogers <irogers@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Fabian Hemmer <copy@copy.sh>,
	Remi Bernon <rbernon@codeweavers.com>,
	Jiri Slaby <jirislaby@kernel.org>,
	linux-perf-users <linux-perf-users@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] perf symbol-elf: fix memory leak: free sdt_note.args
Date: Fri, 04 Jun 2021 17:23:19 +0200	[thread overview]
Message-ID: <3e31a3f86487b31cd5161f57648798a129f13b0a.camel@gmail.com> (raw)
In-Reply-To: <YLokBBmh2+vd9E9d@kernel.org>

Hi,

On Fri, 2021-06-04 at 10:00 -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Jun 03, 2021 at 09:08:46PM -0700, Ian Rogers escreveu:
> > On Wed, Jun 2, 2021 at 3:12 PM Riccardo Mancini <rickyman7@gmail.com> wrote:
> > > 
> > > Reported by ASan.
> > 
> > Did you have a reproducer for getting this to fail?

In case you'd like to add it to the commit message.

$ sudo ./perf record -- sleep 5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.025 MB perf.data (15 samples) ]

=================================================================
==79402==ERROR: LeakSanitizer: detected memory leaks

[...]

Direct leak of 999 byte(s) in 47 object(s) allocated from:
    #0 0x4b7cc7 in strdup (/home/user/linux/source/tools/perf/perf+0x4b7cc7)
    #1 0xac69db in populate_sdt_note /home/user/linux/source/tools/perf/util/symbol-elf.c:2256:15
    #2 0xac2b57 in construct_sdt_notes_list /home/user/linux/source/tools/perf/util/symbol-elf.c:2359:10
    #3 0xac2502 in get_sdt_note_list /home/user/linux/source/tools/perf/util/symbol-elf.c:2394:8
    #4 0xacc6ac in probe_cache__scan_sdt /home/user/linux/source/tools/perf/util/probe-file.c:882:8
    #5 0x7e2949 in build_id_cache__add_sdt_cache /home/user/linux/source/tools/perf/util/build-id.c:619:8
    #6 0x7e233c in build_id_cache__add /home/user/linux/source/tools/perf/util/build-id.c:779:6
    #7 0x7e2b37 in build_id_cache__add_s /home/user/linux/source/tools/perf/util/build-id.c:805:8
    #8 0x7e3e99 in build_id_cache__add_b /home/user/linux/source/tools/perf/util/build-id.c:821:9
    #9 0x7e3166 in dso__cache_build_id /home/user/linux/source/tools/perf/util/build-id.c:889:9
    #10 0x8da7bc in machine__for_each_dso /home/user/linux/source/tools/perf/util/machine.c:3167:7
    #11 0x7e2ec1 in machines__for_each_dso /home/user/linux/source/tools/perf/util/build-id.c:896:12
    #12 0x7e2e46 in __perf_session__cache_build_ids /home/user/linux/source/tools/perf/util/build-id.c:917:9
    #13 0x7e2faa in perf_session__cache_build_ids /home/user/linux/source/tools/perf/util/build-id.c:922:9
    #14 0x8996c8 in write_build_id /home/user/linux/source/tools/perf/util/header.c:327:2
    #15 0x8b76e9 in do_write_feat /home/user/linux/source/tools/perf/util/header.c:3216:9
    #16 0x8ac70d in perf_header__adds_write /home/user/linux/source/tools/perf/util/header.c:3261:7
    #17 0x8abe52 in perf_session__write_header /home/user/linux/source/tools/perf/util/header.c:3353:9
    #18 0x5961ed in record__finish_output /home/user/linux/source/tools/perf/builtin-record.c:1241:2
    #19 0x58e6ca in __cmd_record /home/user/linux/source/tools/perf/builtin-record.c:2060:4
    #20 0x58990b in cmd_record /home/user/linux/source/tools/perf/builtin-record.c:2901:8
    #21 0x7b2a20 in run_builtin /home/user/linux/source/tools/perf/perf.c:313:11
    #22 0x7b12ff in handle_internal_command /home/user/linux/source/tools/perf/perf.c:365:8
    #23 0x7b2583 in run_argv /home/user/linux/source/tools/perf/perf.c:409:2
    #24 0x7b0d79 in main /home/user/linux/source/tools/perf/perf.c:539:3
    #25 0x7effc1a65b74 in __libc_start_main /usr/src/debug/glibc-2.33-8.fc34.x86_64/csu/../csu/libc-start.c:332:16

Thanks,
Riccardo

> > 
> > > Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
> > 
> > Acked-by: Ian Rogers <irogers@google.com>
> 
> Thanks, applied.
> 
> - Arnaldo
> 
>  
> > Thanks,
> > Ian
> > 
> > > ---
> > >  tools/perf/util/symbol-elf.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> > > index 4c56aa8374344..a73345730ba90 100644
> > > --- a/tools/perf/util/symbol-elf.c
> > > +++ b/tools/perf/util/symbol-elf.c
> > > @@ -2412,6 +2412,7 @@ int cleanup_sdt_note_list(struct list_head *sdt_notes)
> > > 
> > >         list_for_each_entry_safe(pos, tmp, sdt_notes, note_list) {
> > >                 list_del_init(&pos->note_list);
> > > +               zfree(&pos->args);
> > >                 zfree(&pos->name);
> > >                 zfree(&pos->provider);
> > >                 free(pos);
> > > --
> > > 2.31.1
> > > 
> 



      reply	other threads:[~2021-06-04 15:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 22:08 [PATCH] perf symbol-elf: fix memory leak: free sdt_note.args Riccardo Mancini
2021-06-04  4:08 ` Ian Rogers
2021-06-04 13:00   ` Arnaldo Carvalho de Melo
2021-06-04 15:23     ` Riccardo Mancini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e31a3f86487b31cd5161f57648798a129f13b0a.camel@gmail.com \
    --to=rickyman7@gmail.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=copy@copy.sh \
    --cc=irogers@google.com \
    --cc=jirislaby@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rbernon@codeweavers.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.