vfork/SPARC problem.

Casper Dik casper@holland.sun.com
Thu Jul 15 02:14:00 GMT 1999


I noticed in egcs 2.95 (and as early as I have them, really), that
the 'working vfork" tests fails when you pass "CFLAGS=-O2".

	$ gcc -O vfork.c
	$ ./a.out
	$ gcc -O2 vfork.c
	$ ./a.out
	Segmentation fault
	$ gcc -v

Reading specs from /usr/local/gnu/lib/gcc-lib/sparc-sun-solaris2/2.95/specs
gcc version 2.95 19990712 (prerelease)

This works for gcc 2.8.1

Attached are: vfork.c (a test programma from configure modified to
compile w/o confdefs.
	vfork-O1.s: 	working vfork
	vfork-O2.s: 	failing vfork.

Diffs show:

        nop
        call    vfork, 0
!        nop
!       sethi   %hi(child.3), %o1
        cmp     %o0, 0

----
        nop
        call    vfork, 0
!       sethi   %hi(child.3), %l0
        cmp     %o0, 0
        bge     .LL4

So the broken code drops the nop in the delay slot
and that causes the %l0 register to be clobbered in the
child and %hi(child.3) to be lost when the parent resumes.



More information about the Gcc-bugs mailing list