[PATCH] eal: fix cleanup on Windows

Mattias Rönnblom hofors at lysator.liu.se
Fri Nov 8 16:43:29 CET 2024


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 at redhat.com>
> Signed-off-by: Thomas Monjalon <thomas at 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 at ericsson.com>



More information about the dev mailing list