From: "MOESSBAUER, Felix" <felix.moessbauer@siemens.com>
To: "rostedt@goodmis.org" <rostedt@goodmis.org>
Cc: "linux-trace-devel@vger.kernel.org" <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH 1/1] libtracecmd: fix memory leak on partial reverse iteration
Date: Mon, 24 Nov 2025 09:14:06 +0000 [thread overview]
Message-ID: <e113f523ef34efe5edab24d5dbad5cd40db9ea26.camel@siemens.com> (raw)
In-Reply-To: <20251121120117.20e82d9e@gandalf.local.home>
On Fri, 2025-11-21 at 12:01 -0500, Steven Rostedt wrote:
> On Fri, 21 Nov 2025 14:47:49 +0100
> Felix Moessbauer <felix.moessbauer@siemens.com> wrote:
>
> > When calling tracecmd_iterate_events_reverse with a callback that does
> > not always return 0, the trace is only partially iterated. By that, the
> > non-iterated records are leaked, resulting in the error:
> >
> > 1 pages still allocated on cpu <cpu>
> >
> > We fix this by always iterating the remaining events on all selected
> > CPUs. In the full iteration case, this stops on the first record as this
> > is already zero. In the partial iteration case, all remaining records
> > are freed, which is - by construction of the records list - at max a
> > page size.
> >
> > Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> > ---
> > Note, that this bug has been reported in [1].
> >
> > [1] https://lore.kernel.org/linux-trace-devel/0b4fb4b774a8754ed86a9212f0a253304a41245c.camel@siemens.com/
> >
>
> Thanks for the report. I actually found two bugs here.
Hi,
while thinking about it again, I noticed that the callback based
iteration interface relies on some assumptions which are not
documented. While probably obvious, it should be documented what is NOT
allowed to be done inside the callback (i.e. calling any
tracecmd_iterate_* function, but also calling tracecmd_read_* and
alike?).
Best regards,
Felix
--
Siemens AG
Linux Expert Center
Friedrich-Ludwig-Bauer-Str. 3
85748 Garching, Germany
next prev parent reply other threads:[~2025-11-24 9:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 13:47 [PATCH 1/1] libtracecmd: fix memory leak on partial reverse iteration Felix Moessbauer
2025-11-21 17:01 ` Steven Rostedt
2025-11-24 9:14 ` MOESSBAUER, Felix [this message]
2025-11-21 17:11 ` Steven Rostedt
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=e113f523ef34efe5edab24d5dbad5cd40db9ea26.camel@siemens.com \
--to=felix.moessbauer@siemens.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).