This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ 15089] Fixes malloc_trim always trims for large padding
- From: Fernando J V da Silva <fernandojvdasilva at gmail dot com>
- To: Ondřej Bílka <neleai at seznam dot cz>
- Cc: Will Newton <will dot newton at linaro dot org>, libc-alpha <libc-alpha at sourceware dot org>, Fernando Ferraz <fernandoperches at gmail dot com>
- Date: Fri, 6 Dec 2013 01:50:11 -0200
- Subject: Re: [PATCH][BZ 15089] Fixes malloc_trim always trims for large padding
- Authentication-results: sourceware.org; auth=none
- References: <CAEdg5wVxfYRHz2qDoJGx6vs0wSD8X334m+VX-D345+xpZxy+8w at mail dot gmail dot com> <CANu=DmhJEQkaarAp4w7zOpD8UZ=ANgvmKrgw5jVpnjrom7G4Rw at mail dot gmail dot com> <20131120105702 dot GA26441 at domone dot podge> <CAEdg5wXOz0ww6mjm7Yv2QTj=XZWDBUAwufup1MLz8S1gCOekqg at mail dot gmail dot com> <CANu=DmhbRqQmChXhKJPvgD37Dv6HCzRMSJ4TW+9RZvzbk4H6uQ at mail dot gmail dot com> <CAEdg5wWHj6Pq4N37CfuxTP_+ry3qtE7BWPk0dXmXDonBTvd4kw at mail dot gmail dot com> <20131204003810 dot GB20463 at domone dot podge>
Hi OndÅej!
Thanks for the reply! Here is the patch with the change as you asked.
Cheers,
Fernando J V da Silva
2013/12/3 OndÅej BÃlka <neleai@seznam.cz>:
> On Thu, Nov 21, 2013 at 09:11:20PM -0200, Fernando J V da Silva wrote:
>> Hi Will!
>>
>> Ah, Ok! I just got confused... Thanks for explaining!
>> Here is the patch again, now with the changes you requested in the
>> first e-mail and with ChangeLog inside the commit message.
>>
>> Cheers,
>>
> A changed patch no longer applies as we added LIBC_PROBE in meantime.
>
> Could you send patch that replaces deleted if by if (1) and then I could
> fix formatting.
From 18aa066d8a781176f20e5f39030330e9d041bff5 Mon Sep 17 00:00:00 2001
From: Fernando J. V. da Silva <fernandojvdasilva@gmail.com>
Date: Fri, 6 Dec 2013 01:40:50 -0200
Subject: [PATCH] Fix BZ #15089: malloc_trim always trim for large padding.
At systrim(), if the heap top size is bigger than requested pad, then
doesn't calculate size to call sbrk().
2013-11-21 Fernando J. V. da Silva <fernandojvdasilva@gmail.com>
[BZ #15089]
* malloc/malloc.c: Exit systrim() if pad is bigger than heap top size.
---
malloc/malloc.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/malloc/malloc.c b/malloc/malloc.c
index be472b2..42f7389 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -2712,15 +2712,19 @@ static int systrim(size_t pad, mstate av)
char* current_brk; /* address returned by pre-check sbrk call */
char* new_brk; /* address returned by post-check sbrk call */
size_t pagesz;
+ long top_area;
pagesz = GLRO(dl_pagesize);
top_size = chunksize(av->top);
/* Release in pagesize units, keeping at least one page */
- extra = (top_size - pad - MINSIZE - 1) & ~(pagesz - 1);
+ top_area = top_size - MINSIZE - 1;
+ if (top_area <= pad)
+ return 0;
- if (extra > 0) {
+ extra = (top_area - pad) & ~(pagesz - 1);
+ if (1) {
/*
Only proceed if end of memory is where we last set it.
This avoids problems if there were foreign sbrk calls.
--
1.7.1