[PATCH] malloc: Fix MALLOC_DEBUG
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Aug 5 16:46:11 GMT 2025
On 04/08/25 10:01, Wilco Dijkstra wrote:
>
> MALLOC_DEBUG only works on locked arenas, so move the call to
> check_inuse_chunk from __libc_free() to _int_free_chunk().
> Regress now passes if MALLOC_DEBUG is enabled - OK for commit?
LGTM, thanks. Should we define it for libc_malloc_debug.so?
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
>
> ---
>
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index 17fef8c2adbd37dce9353c735f85a06f761b5a4f..b3f5a446461b607dd9181a2107d3e8809373e310 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -3460,8 +3460,6 @@ __libc_free (void *mem)
> if (__glibc_unlikely (misaligned_chunk (p)))
> return malloc_printerr_tail ("free(): invalid pointer");
>
> - check_inuse_chunk (arena_for_chunk (p), p);
> -
> #if USE_TCACHE
> if (__glibc_likely (size < mp_.tcache_max_bytes && tcache != NULL))
> {
> @@ -4678,6 +4676,8 @@ _int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size)
> {
> mchunkptr nextchunk = chunk_at_offset(p, size);
>
> + check_inuse_chunk (av, p);
> +
> /* Lightweight tests: check whether the block is already the
> top block. */
> if (__glibc_unlikely (p == av->top))
>
More information about the Libc-alpha
mailing list