* [PATCH] Fix malloc
@ 2002-03-13 3:47 Jakub Jelinek
2002-03-13 4:11 ` Wolfram Gloger
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2002-03-13 3:47 UTC (permalink / raw)
To: Ulrich Drepper, Wolfram Gloger; +Cc: Glibc hackers
Hi!
#include <stdlib.h>
void main (void)
{
malloc (0x3ffffffc);
}
crashes with new malloc on an i686 box with 256MB of RAM and
no overcommit.
The issue is that if MORECORE_FAILURE != MMAP_FAILED, then
if brk fails and mmap fails too, it would leave brk set to MMAP_FAILED
and so code below would consider it as if brk was successfully set.
2002-03-13 Jakub Jelinek <jakub@redhat.com>
* malloc/malloc.c (sYSMALLOc): Set brk to MORECORE_FAILURE if mmap
failed.
--- libc/malloc/malloc.c.jj Fri Feb 8 12:04:04 2002
+++ libc/malloc/malloc.c Wed Mar 13 12:44:48 2002
@@ -2838,7 +2838,8 @@ static Void_t* sYSMALLOc(nb, av) INTERNA
bridge regions.
*/
set_noncontiguous(av);
- }
+ } else
+ brk = (char *)(MORECORE_FAILURE);
}
#endif
}
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix malloc
2002-03-13 3:47 [PATCH] Fix malloc Jakub Jelinek
@ 2002-03-13 4:11 ` Wolfram Gloger
2002-03-13 15:23 ` Ulrich Drepper
0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Gloger @ 2002-03-13 4:11 UTC (permalink / raw)
To: jakub; +Cc: libc-hacker
Hi,
> The issue is that if MORECORE_FAILURE != MMAP_FAILED, then
> if brk fails and mmap fails too, it would leave brk set to MMAP_FAILED
> and so code below would consider it as if brk was successfully set.
Clearly you're right. I'd rather not change 'brk' at all though,
like below:
2002-03-13 Wolfram Gloger <wg@malloc.de>
* malloc/malloc.c (sYSMALLOc): Don't change brk if mmap
failed.
--- malloc.c 2002/02/15 09:30:28 1.6
+++ malloc.c 2002/03/13 12:06:55
@@ -2824,11 +2824,12 @@
/* Don't try if size wraps around 0 */
if ((unsigned long)(size) > (unsigned long)(nb)) {
- brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));
+ char *mbrk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));
- if (brk != MAP_FAILED) {
+ if (mbrk != MAP_FAILED) {
/* We do not need, and cannot use, another sbrk call to find end */
+ brk = mbrk;
snd_brk = brk + size;
/*
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix malloc
2002-03-13 4:11 ` Wolfram Gloger
@ 2002-03-13 15:23 ` Ulrich Drepper
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Drepper @ 2002-03-13 15:23 UTC (permalink / raw)
To: Wolfram Gloger; +Cc: Jakub Jelinek, libc-hacker
[-- Attachment #1: Type: text/plain, Size: 439 bytes --]
On Wed, 2002-03-13 at 04:11, Wolfram Gloger wrote:
> 2002-03-13 Wolfram Gloger <wg@malloc.de>
>
> * malloc/malloc.c (sYSMALLOc): Don't change brk if mmap
> failed.
I've applied this patch. Thanks,
--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-03-13 23:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-13 3:47 [PATCH] Fix malloc Jakub Jelinek
2002-03-13 4:11 ` Wolfram Gloger
2002-03-13 15:23 ` Ulrich Drepper
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 read-only IMAP folder(s) and NNTP newsgroup(s).