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: Tue, 25 Nov 2025 15:17:06 +0000 [thread overview]
Message-ID: <aa7d58fc03dd7a43b51ad4daa8ad9e328a16883c.camel@siemens.com> (raw)
In-Reply-To: <20251124115840.7a4de310@gandalf.local.home>
On Mon, 2025-11-24 at 11:58 -0500, Steven Rostedt wrote:
> On Mon, 24 Nov 2025 09:14:06 +0000
> "MOESSBAUER, Felix" <felix.moessbauer@siemens.com> wrote:
>
> > 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?).
>
> Agreed that this should be documented. I wouldn't say it is "NOT" allowed,
> but instead specify what the side effects are.
Agree, makes sense.
>
> I think stating how the iterator is somewhat implemented is good, as it
> should allow the user to assume its behavior.
>
> Basically saying that the internal cursor of the iterator is:
>
> do {
> record = tracecmd_read_next_data(handle, &cpu);
> if (!record)
> break;
> ret = callback(handle, record, cpu, data);
> } while (!ret);
>
> And state that any reads in the callback can change the iterator, and cause
> it to behave differently, just like it would in the above code.
I'm just wondering if all possible / reasonable user interactions lead
to a state that does not leak memory. Anyways, just documenting it is
IMHO sufficient.
>
> Hmm, my fix of the reverse code had the last record get read again. That's
> different than the iterator itself. I should get rid of the "- 4" and make
> the continue read the next record after the one last read too.
Yep!
Felix
>
> Thanks,
>
> -- Steve
--
Siemens AG
Linux Expert Center
Friedrich-Ludwig-Bauer-Str. 3
85748 Garching, Germany
next prev parent reply other threads:[~2025-11-25 15:17 UTC|newest]
Thread overview: 6+ 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
2025-11-24 16:58 ` Steven Rostedt
2025-11-25 15:17 ` 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=aa7d58fc03dd7a43b51ad4daa8ad9e328a16883c.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).