malloc: bug or feature ?

James R. Van Artsalen james at
Fri Apr 9 01:32:17 PDT 2004

Peter Wemm wrote:

> The SEGV looks suspicious though.  I wonder if malloc is trying to put 
> the junk in without checking if malloc failed.

Attached is a proposed patch for this bug.  It fixes the test program 
(which now fails the ASSERT in main() as it ought to).  I have not 
tested it in any other way.

Without this change I expect every brk(2) call that fails to crash.

I haven't checked for equivalent bugs in other functions.
-------------- next part --------------
--- lib/libc/amd64/sys/brk.S.~1~	Sat May 24 12:35:23 2003
+++ lib/libc/amd64/sys/brk.S	Fri Apr  9 02:02:22 2004
@@ -78,6 +78,7 @@
 	popq	%rdi
+	popq	%rdi
 #ifdef PIC
 	movq	PIC_GOT(HIDENAME(cerror)),%rdx
 	jmp	*%rdx

More information about the freebsd-amd64 mailing list