public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [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

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).