This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] [v2] malloc: Do not corrupt the top of a threaded heap if top chunk is MINSIZE [BZ #18502]
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: Mel Gorman <mgorman at suse dot de>
- Cc: Siddhesh Poyarekar <siddhesh at redhat dot com>, Carlos O'Donell <carlos at redhat dot com>, libc-alpha at sourceware dot org
- Date: Mon, 08 Jun 2015 13:48:03 +0200
- Subject: Re: [PATCH] [v2] malloc: Do not corrupt the top of a threaded heap if top chunk is MINSIZE [BZ #18502]
- Authentication-results: sourceware.org; auth=none
- References: <20150608103743 dot GN26425 at suse dot de>
Mel Gorman <mgorman@suse.de> writes:
> diff --git a/malloc/arena.c b/malloc/arena.c
> index 2466697d1aa7..b932574ccaf8 100644
> --- a/malloc/arena.c
> +++ b/malloc/arena.c
> @@ -698,6 +698,9 @@ heap_trim (heap_info *heap, size_t pad)
> /* Uses similar logic for per-thread arenas as the main arena with systrim
> by preserving the top pad and at least a page. */
> top_size = chunksize (top_chunk);
> + if (top_size == MINSIZE)
> + return 0;
> +
> top_area = top_size - MINSIZE - 1;
> if (top_area <= pad)
> return 0;
>
For rebustness I'd check for top_area < 0 instead.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."