[gnu.g++.bug] Why some G++ programs failed on the Sun-3, but worked on the Sun-4

dupuy@CS.COLUMBIA.EDU (Alexander Dupuy) (04/25/89)

GNU G++ 1.34.1 / SunOS 4.0.1 / Sun-3 (& not Sun-4)

They were all dying in malloc, the first time it was called (by on_exit, in the
G++ startup code).  When linked with Sun's debugging malloc, a diagnostic was
given about "free: illegal address (0x21af2)".

The problem was that the value returned by sbrk was not fullword aligned, and
this tickled a bug in Sun's malloc implementation, which uses free to add newly
sbrk'd space to the free-"list".

I'm amazed this hasn't bit anyone before.  The bug wasn't tickled on the Sun-4,
since on the sparc, ld++ fullword aligns common blocks (and thus the end of bss
and beginning of sbrk'd space).

The right fix is to eliminate the bug in morecore, which (having source) I have
done.  But it is probably desirable to fullword align comon blocks on all
architectures (for performance reasons), and since this is apparently the
behavior of the Sun linker, it would be useful for GNU ld and ld++ to do this
on Suns.

@alex
-- 
inet: dupuy@cs.columbia.edu
uucp: ...!rutgers!cs.columbia.edu!dupuy