cvs commit: src/sys/i386/i386 trap.c
Alan Cox
alc at cs.rice.edu
Mon Jul 30 20:12:02 UTC 2007
Alfred Perlstein wrote:
> * Don Lewis <truckman at FreeBSD.org> [070730 00:17] wrote:
>
>> After installing this patch, the bootstrap in the pm3-base port still
>> fails. I installed pm3-base from the 6-STABLE package, and it isn't
>> able to compile any of the other ports. I suspect the reason for the
>> latter is that it is new enough to use sendsig() and not osendsig().
>> This makes sense because osendsig is a COMPAT_43 function and the binary
>> is a lot newer than that.
>>
>> To preserve the "kludge" ABI as much as possible, I think it would be
>> necessary to move the assignment to sc_err into the if-else block that
>> checks to see if the signal handler was installed with the SA_SIGIFNO
>> flag, and to make the same change in sendsig(), osendsig(), and
>> freebsd4_sendsig(). This will break the wine port unless it uses
>> SA_SIGINFO.
>>
>>
>> As an alternative, I've got a set of patches to pm3-base to get it
>> working on -CURRENT. It wasn't too hard to fix the bootstrap to use the
>> "undocumented 4th arg" to the signal handler that is mentioned in
>> i386/include/sigframe.h. The rest of the patches change the low-level
>> Module-3 code to use sigaction() with the SA_SIGINFO flag instead of
>> using a mixture of sigaction() (without SA_SIGINFO) and sigvec().
>> I'll post the patches for testing once I've had a chance to clean them
>> up some more.
>>
>
> This sounds really, really hackish. I talked to Alan Cox about this
> over the weekend and he said, if I have this right, that supposedly
> a correct program actually does get the correct info on the stack
> as an argument to their signal callback. m3 should be fixed.
>
>
I think I was unclear. I agree with what Don is proposing. I was
referring to the "undocumented 4th arg" when I said that a program would
receive "the correct info on the stack as an argument". I'm not,
however, sure why FreeBSD never documented the 4th argument. It is not
only implemented by some other flavors of Unix but it is actually
documented, for example, from a Solaris 2.8 man page:
The handler routine can be declared:
void handler(int sig, int code, struct sigcontext *scp, char *addr);
Here sig is the signal number; code is a parameter of cer-
tain signals that provides additional detail; scp is a
pointer to the sigcontext structure (defined in signal.h),
used to restore the context from before the signal; and addr
is additional address information.
Also, that FreeBSD used to clobber tf_err with the faulting address made
it rather challenging to determine whether the SIGBUS/SIGSEGV was caused
by a read or a write access. So, not clobbering tf_err is a good
thing. Fortunately, Modula-3's garbage collector didn't care about
this, but some other applications do.
Alan
More information about the cvs-src
mailing list