From: Andre Muezerie <andremue@linux.microsoft.com>
To: David Marchand <david.marchand@redhat.com>
Cc: dev@dpdk.org, dmitry.kozliuk@gmail.com, roretzla@linux.microsoft.com
Subject: Re: [PATCH v2 2/2] test/strsep: add tests for function strsep()
Date: Tue, 22 Jul 2025 09:37:45 -0700 [thread overview]
Message-ID: <20250722163745.GA26460@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <CAJFAV8x4qO9-y+0C_PoJsw0eYmVcPs+CzpfPBvD0=opC7KQ-2w@mail.gmail.com>
On Tue, Jul 22, 2025 at 04:30:57PM +0200, David Marchand wrote:
> Hello Andre,
>
> On Mon, Jul 21, 2025 at 10:39 PM Andre Muezerie
> <andremue@linux.microsoft.com> wrote:
> > diff --git a/app/test/test_strsep.c b/app/test/test_strsep.c
> > new file mode 100644
> > index 0000000000..19df8f31ee
> > --- /dev/null
> > +++ b/app/test/test_strsep.c
> > @@ -0,0 +1,108 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright (C) 2025 Microsoft Corporation
> > + */
> > +
> > +#include <string.h>
> > +#include <rte_os_shim.h>
> > +
> > +#include "test.h"
> > +
> > +static int
> > +test_strsep_helper(const char *str, const char *delim,
> > + const char * const expected_tokens[], size_t expected_tokens_count)
> > +{
> > + char *s = str != NULL ? strdup(str) : NULL;
> > + const char *token;
> > + for (size_t i = 0; i < expected_tokens_count; i++) {
> > + token = strsep(&s, delim);
>
> The reference to the dupped string gets lost, since calling strsep updates s.
> Caught by ASan:
>
> ==49990==ERROR: LeakSanitizer: detected memory leaks
>
> Direct leak of 51 byte(s) in 4 object(s) allocated from:
> #0 0x5632dd8cbe83 in strdup
> (/home/runner/work/dpdk/dpdk/build/app/dpdk-test+0x271e83) (BuildId:
> 01a7571ab7814bc83923733b3dae34d28e6ff3e1)
> #1 0x5632de39bad2 in test_strsep_helper
> /home/runner/work/dpdk/dpdk/build/../app/test/test_strsep.c:14:26
> #2 0x5632dd91d86f in unit_test_suite_runner
> /home/runner/work/dpdk/dpdk/build/../app/test/test.c:364:20
> #3 0x5632dd91c2b0 in cmd_autotest_parsed
> /home/runner/work/dpdk/dpdk/build/../app/test/commands.c:68:10
> #4 0x7fba8b3bfc58 in __cmdline_parse
> /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline_parse.c:296:3
> #5 0x7fba8b3bfc58 in cmdline_parse
> /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline_parse.c:305:9
> #6 0x7fba8b3bcbf7 in cmdline_valid_buffer
> /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline.c:25:8
> #7 0x7fba8b3c50ec in rdline_char_in
> /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline_rdline.c:456:5
> #8 0x7fba8b3bcfde in cmdline_in
> /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline.c:154:9
> #9 0x5632dd91d2ba in main
> /home/runner/work/dpdk/dpdk/build/../app/test/test.c:231:15
> #10 0x7fba89a29d8f in __libc_start_call_main
> csu/../sysdeps/nptl/libc_start_call_main.h:58:16
>
> SUMMARY: AddressSanitizer: 51 byte(s) leaked in 4 allocation(s).
> ------------------------------------------------------------------------------
>
>
> --
> David Marchand
Thanks for sending this info. I'll send out a fixed version.
next prev parent reply other threads:[~2025-07-22 16:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 13:22 [PATCH 1/2] eal: add strsep() for Windows builds Andre Muezerie
2025-05-16 13:22 ` [PATCH 2/2] test/strsep: add tests for function strsep() Andre Muezerie
2025-07-21 20:39 ` [PATCH v2 1/2] eal: add strsep() for Windows builds Andre Muezerie
2025-07-21 20:39 ` [PATCH v2 2/2] test/strsep: add tests for function strsep() Andre Muezerie
2025-07-22 14:30 ` David Marchand
2025-07-22 16:37 ` Andre Muezerie [this message]
2025-07-22 16:38 ` [PATCH v3 1/2] eal: add strsep() for Windows builds Andre Muezerie
2025-07-22 16:38 ` [PATCH v3 2/2] test/strsep: add tests for function strsep() Andre Muezerie
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=20250722163745.GA26460@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
--to=andremue@linux.microsoft.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=roretzla@linux.microsoft.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 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).