Subject: Re: lib/655: sigsetjmp/setlongjmp bug?
To: James Jegers <jimj@enigma.cs.uwm.edu>
From: Chris G Demetriou <Chris_G_Demetriou@LAGAVULIN.PDL.CS.CMU.EDU>
List: netbsd-bugs
Date: 12/23/1994 13:50:50
> >Description:
> 	
> 	 The sigsetjmp and siglongjmp functions don't appear to be working as
> 	 they should, and one of the programs which break is xdm.
> 	I tried writting a program using setjmp,longjmp and that works fine, but
> 	when I change it to the sig... functions it doesn't appear to work.
> >How-To-Repeat:
> [ wonderful example elided. ]
> 	
> >Fix:
>  	Bring back the  libc/arch/i386/gen/sigsetjmp.S file?  Works for me..:-)

You can quote me as having screamed, and as having growled a bit.

unless i'm mistaken, your joking fix is the only one that will work...

you see, the functions that are called by sigsetjmp() (i.e. setjmp()
or _setjmp()) work just fine, and properly save the address that
they're supposed to jump to...

except they don't save the stack frame of the function that invoked
them.  this includes _its_ return address.

so, the return address of the siglongjmp invocation is sitting on the
stack when longjmp() or _longjmp() is invoked, and thus, the routine
that gets jumped to (i.e. siglongjmp()) returns to an address that
wasn't _its_ invocation.


This is a classic misuse of the setjmp() and longjmp() families of
functions.  I'm going to be in berkeley two weeks from now.  i think
i'm going to bring a boot...  This never, ever worked, on either the
i386 or the hp300.  i just tried it out on vangogh (CSRG's development
machine), and lo and behold it didn't work.



chris