Subject: Re: kern/14855: sparc sigreturn sometimes trashes user stack
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Chuck Silvers <chuq@chuq.com>
List: netbsd-bugs
Date: 12/08/2001 22:51:28
this may be related to another bug with signal handling that I spent
some time investigating last weekend.  the program below consistently
reproduces the problem.  on a pc the program correctly prints:

56 spathi2:~ # ./bug-fork-vs-signal 
sighup
sighup
yo
in child


whereas on a sparc or sparc64, it prints:

1 sparc5:~ # ./bug-fork-vs-signal 
sighup
sighup
yo
Dec  8 22:48:06 sparc5 /netbsd: pid 194 (bug-fork-vs-sign), uid 0: exited on signal 4 (core dumped)


-Chuck



#include <signal.h>

void
sighup()
{
        write(1, "sighup\n", 7);
}

int
main()
{
        signal(SIGHUP, sighup);

        switch (fork()) {
        case 0:
                write(1, "in child\n", 9);
                _exit(0);

        case -1:
                write(1, "fork failed\n", 12);
                _exit(0);

        default:
                kill(0, SIGHUP);
        }

        write(1, "yo\n", 3);
        _exit(0);
}





On Fri, Dec 07, 2001 at 05:27:00PM +0100, Manuel Bouyer wrote:
> On Thu, Dec 06, 2001 at 12:02:35PM -0800, Wolfgang Rupprecht wrote:
> > >Description:
> > 
> >     The user's stack gets trashed a small percentage of the time by
> >     sigreturn(); In this test program a "can't happen" default branch
> >     does indeed happen with disturbing frequency.
> 
> I could also reproduce this on a SS10 (sun4m) with a 1.5.2 userland but
> -current kernel.
> This also happens on a IPX (sun4c) with a kernel of end november and userland
> of early august.
> But I can't reproduce it on any machine if compiled with -O1 instead of -O2
> 
> --
> Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
> --