DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal: fix cleanup on Windows
@ 2024-11-08 13:08 Thomas Monjalon
  2024-11-08 13:11 ` David Marchand
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Thomas Monjalon @ 2024-11-08 13:08 UTC (permalink / raw)
  To: dev
  Cc: David Marchand, Mattias Rönnblom, Tyler Retzlaff,
	Stephen Hemminger, Morten Brørup, Chengwen Feng,
	Konstantin Ananyev

The memory allocated with _aligned_malloc()
must be released with _aligned_free() on Windows.

The POSIX free() was called in eal_lcore_var_cleanup(),
called in rte_eal_cleanup(), and triggered a heap corruption:
exit status 3221226356 or signal 3221226228 SIGinvalid
with MALLOC_PERTURB_=86

Fixes: 5bce9bed67ad ("eal: add static per-lcore memory allocation facility")

Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/eal/common/eal_common_lcore_var.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/eal/common/eal_common_lcore_var.c b/lib/eal/common/eal_common_lcore_var.c
index 0e9e8e4804..a1b2458839 100644
--- a/lib/eal/common/eal_common_lcore_var.c
+++ b/lib/eal/common/eal_common_lcore_var.c
@@ -54,7 +54,6 @@ lcore_var_alloc(size_t size, size_t align)
 		current_buffer = _aligned_malloc(alloc_size, RTE_CACHE_LINE_SIZE);
 #else
 		current_buffer = aligned_alloc(RTE_CACHE_LINE_SIZE, alloc_size);
-
 #endif
 		RTE_VERIFY(current_buffer != NULL);
 
@@ -108,7 +107,11 @@ eal_lcore_var_cleanup(void)
 	while (current_buffer != NULL) {
 		struct lcore_var_buffer *prev = current_buffer->prev;
 
+#ifdef RTE_EXEC_ENV_WINDOWS
+		_aligned_free(current_buffer);
+#else
 		free(current_buffer);
+#endif
 
 		current_buffer = prev;
 	}
-- 
2.46.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] eal: fix cleanup on Windows
  2024-11-08 13:08 [PATCH] eal: fix cleanup on Windows Thomas Monjalon
@ 2024-11-08 13:11 ` David Marchand
  2024-11-08 13:33 ` Morten Brørup
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: David Marchand @ 2024-11-08 13:11 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Mattias Rönnblom, Tyler Retzlaff, Stephen Hemminger,
	Morten Brørup, Chengwen Feng, Konstantin Ananyev

On Fri, Nov 8, 2024 at 2:08 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> The memory allocated with _aligned_malloc()
> must be released with _aligned_free() on Windows.
>
> The POSIX free() was called in eal_lcore_var_cleanup(),
> called in rte_eal_cleanup(), and triggered a heap corruption:
> exit status 3221226356 or signal 3221226228 SIGinvalid
> with MALLOC_PERTURB_=86
>
> Fixes: 5bce9bed67ad ("eal: add static per-lcore memory allocation facility")
>
> Reported-by: David Marchand <david.marchand@redhat.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Reviewed-by: David Marchand <david.marchand@redhat.com>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] eal: fix cleanup on Windows
  2024-11-08 13:08 [PATCH] eal: fix cleanup on Windows Thomas Monjalon
  2024-11-08 13:11 ` David Marchand
@ 2024-11-08 13:33 ` Morten Brørup
  2024-11-08 13:39 ` Dmitry Kozlyuk
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Morten Brørup @ 2024-11-08 13:33 UTC (permalink / raw)
  To: Thomas Monjalon, dev
  Cc: David Marchand, Mattias Rönnblom, Tyler Retzlaff,
	Stephen Hemminger, Chengwen Feng, Konstantin Ananyev

Reviewed-by: Morten Brørup <mb@smartsharesystems.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] eal: fix cleanup on Windows
  2024-11-08 13:08 [PATCH] eal: fix cleanup on Windows Thomas Monjalon
  2024-11-08 13:11 ` David Marchand
  2024-11-08 13:33 ` Morten Brørup
@ 2024-11-08 13:39 ` Dmitry Kozlyuk
  2024-11-08 15:43 ` Mattias Rönnblom
  2024-11-08 16:00 ` Stephen Hemminger
  4 siblings, 0 replies; 8+ messages in thread
From: Dmitry Kozlyuk @ 2024-11-08 13:39 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, David Marchand, Mattias Rönnblom, Tyler Retzlaff,
	Stephen Hemminger, Morten Brørup, Chengwen Feng,
	Konstantin Ananyev

2024-11-08 14:08 (UTC+0100), Thomas Monjalon:
> The memory allocated with _aligned_malloc()
> must be released with _aligned_free() on Windows.
> 
> The POSIX free() was called in eal_lcore_var_cleanup(),
> called in rte_eal_cleanup(), and triggered a heap corruption:
> exit status 3221226356 or signal 3221226228 SIGinvalid
> with MALLOC_PERTURB_=86
> 
> Fixes: 5bce9bed67ad ("eal: add static per-lcore memory allocation facility")
> 
> Reported-by: David Marchand <david.marchand@redhat.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] eal: fix cleanup on Windows
  2024-11-08 13:08 [PATCH] eal: fix cleanup on Windows Thomas Monjalon
                   ` (2 preceding siblings ...)
  2024-11-08 13:39 ` Dmitry Kozlyuk
@ 2024-11-08 15:43 ` Mattias Rönnblom
  2024-11-08 21:57   ` Thomas Monjalon
  2024-11-08 16:00 ` Stephen Hemminger
  4 siblings, 1 reply; 8+ messages in thread
From: Mattias Rönnblom @ 2024-11-08 15:43 UTC (permalink / raw)
  To: Thomas Monjalon, dev
  Cc: David Marchand, Mattias Rönnblom, Tyler Retzlaff,
	Stephen Hemminger, Morten Brørup, Chengwen Feng,
	Konstantin Ananyev

On 2024-11-08 14:08, Thomas Monjalon wrote:
> The memory allocated with _aligned_malloc()
> must be released with _aligned_free() on Windows.
> 
> The POSIX free() was called in eal_lcore_var_cleanup(),

Referring to free() as a part of POSIX is true, but a bit misleading, 
since it's also standard C.

> called in rte_eal_cleanup(), and triggered a heap corruption:
> exit status 3221226356 or signal 3221226228 SIGinvalid
> with MALLOC_PERTURB_=86
> 
> Fixes: 5bce9bed67ad ("eal: add static per-lcore memory allocation facility")
> 
> Reported-by: David Marchand <david.marchand@redhat.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>   lib/eal/common/eal_common_lcore_var.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/eal/common/eal_common_lcore_var.c b/lib/eal/common/eal_common_lcore_var.c
> index 0e9e8e4804..a1b2458839 100644
> --- a/lib/eal/common/eal_common_lcore_var.c
> +++ b/lib/eal/common/eal_common_lcore_var.c
> @@ -54,7 +54,6 @@ lcore_var_alloc(size_t size, size_t align)
>   		current_buffer = _aligned_malloc(alloc_size, RTE_CACHE_LINE_SIZE);
>   #else
>   		current_buffer = aligned_alloc(RTE_CACHE_LINE_SIZE, alloc_size);
> -
>   #endif
>   		RTE_VERIFY(current_buffer != NULL);
>   
> @@ -108,7 +107,11 @@ eal_lcore_var_cleanup(void)
>   	while (current_buffer != NULL) {
>   		struct lcore_var_buffer *prev = current_buffer->prev;
>   
> +#ifdef RTE_EXEC_ENV_WINDOWS
> +		_aligned_free(current_buffer);
> +#else
>   		free(current_buffer);
> +#endif
>   
>   		current_buffer = prev;
>   	}

Reviewed-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] eal: fix cleanup on Windows
  2024-11-08 13:08 [PATCH] eal: fix cleanup on Windows Thomas Monjalon
                   ` (3 preceding siblings ...)
  2024-11-08 15:43 ` Mattias Rönnblom
@ 2024-11-08 16:00 ` Stephen Hemminger
  2024-11-08 17:43   ` Morten Brørup
  4 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2024-11-08 16:00 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, David Marchand, Mattias Rönnblom, Tyler Retzlaff,
	Morten Brørup, Chengwen Feng, Konstantin Ananyev

On Fri,  8 Nov 2024 14:08:21 +0100
Thomas Monjalon <thomas@monjalon.net> wrote:

> The memory allocated with _aligned_malloc()
> must be released with _aligned_free() on Windows.
> 
> The POSIX free() was called in eal_lcore_var_cleanup(),
> called in rte_eal_cleanup(), and triggered a heap corruption:
> exit status 3221226356 or signal 3221226228 SIGinvalid
> with MALLOC_PERTURB_=86
> 
> Fixes: 5bce9bed67ad ("eal: add static per-lcore memory allocation facility")
> 
> Reported-by: David Marchand <david.marchand@redhat.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Is there anyway to use the function attributes to catch this at compile
time (for Gcc builds).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] eal: fix cleanup on Windows
  2024-11-08 16:00 ` Stephen Hemminger
@ 2024-11-08 17:43   ` Morten Brørup
  0 siblings, 0 replies; 8+ messages in thread
From: Morten Brørup @ 2024-11-08 17:43 UTC (permalink / raw)
  To: Stephen Hemminger, Thomas Monjalon
  Cc: dev, David Marchand, Mattias Rönnblom, Tyler Retzlaff,
	Chengwen Feng, Konstantin Ananyev

> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Friday, 8 November 2024 17.01
> 
> On Fri,  8 Nov 2024 14:08:21 +0100
> Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > The memory allocated with _aligned_malloc()
> > must be released with _aligned_free() on Windows.
> >
> > The POSIX free() was called in eal_lcore_var_cleanup(),
> > called in rte_eal_cleanup(), and triggered a heap corruption:
> > exit status 3221226356 or signal 3221226228 SIGinvalid
> > with MALLOC_PERTURB_=86
> >
> > Fixes: 5bce9bed67ad ("eal: add static per-lcore memory allocation
> facility")
> >
> > Reported-by: David Marchand <david.marchand@redhat.com>
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> 
> Is there anyway to use the function attributes to catch this at compile
> time (for Gcc builds).

I took a look at it, and it boils down to building for a Windows environment, where RTE_EXEC_ENV_WINDOWS is defined, and then the alloc function attributes are disabled.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] eal: fix cleanup on Windows
  2024-11-08 15:43 ` Mattias Rönnblom
@ 2024-11-08 21:57   ` Thomas Monjalon
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2024-11-08 21:57 UTC (permalink / raw)
  To: Mattias Rönnblom
  Cc: dev, David Marchand, Mattias Rönnblom, Tyler Retzlaff,
	Stephen Hemminger, Morten Brørup, Chengwen Feng,
	Konstantin Ananyev

08/11/2024 16:43, Mattias Rönnblom:
> On 2024-11-08 14:08, Thomas Monjalon wrote:
> > The memory allocated with _aligned_malloc()
> > must be released with _aligned_free() on Windows.
> > 
> > The POSIX free() was called in eal_lcore_var_cleanup(),
> 
> Referring to free() as a part of POSIX is true, but a bit misleading, 
> since it's also standard C.
> 
> > called in rte_eal_cleanup(), and triggered a heap corruption:
> > exit status 3221226356 or signal 3221226228 SIGinvalid
> > with MALLOC_PERTURB_=86
> > 
> > Fixes: 5bce9bed67ad ("eal: add static per-lcore memory allocation facility")
> > 
> > Reported-by: David Marchand <david.marchand@redhat.com>
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> 
> Reviewed-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>

Applied



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-08 21:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-08 13:08 [PATCH] eal: fix cleanup on Windows Thomas Monjalon
2024-11-08 13:11 ` David Marchand
2024-11-08 13:33 ` Morten Brørup
2024-11-08 13:39 ` Dmitry Kozlyuk
2024-11-08 15:43 ` Mattias Rönnblom
2024-11-08 21:57   ` Thomas Monjalon
2024-11-08 16:00 ` Stephen Hemminger
2024-11-08 17:43   ` Morten Brørup

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).