Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/lib/libc/softfloat



Module Name:    src
Committed By:   riastradh
Date:           Sun Apr 27 15:23:27 UTC 2025

Modified Files:
        src/lib/libc/softfloat: softfloat-specialize

Log Message:
libc softfloat: Make SIGFPE for trapped fp exceptions non-ignorable.

In hardfloat, when the kernel delivers SIGFPE for a floating-point
exception trap, if SIGFPE is masked or ignored, it is handled _as if_
SIGFPE were unmasked and had the default signal disposition:

    964         /*
    965          * If the signal is masked or ignored, then unmask it and
    966          * reset it to the default action so that the process or
    967          * its tracer will be notified.
    968          */
    969         const bool ignored = action == SIG_IGN;
    970         if (masked || ignored) {
    971                 mutex_enter(&ps->sa_mutex);
    972                 sigdelset(mask, signo);
    973                 sigdelset(&p->p_sigctx.ps_sigcatch, signo);
    974                 sigdelset(&p->p_sigctx.ps_sigignore, signo);
    975                 sigdelset(&SIGACTION_PS(ps, signo).sa_mask, signo);
    976                 SIGACTION_PS(ps, signo).sa_handler = SIG_DFL;
    977                 mutex_exit(&ps->sa_mutex);
    978         }

https://nxr.netbsd.org/xref/src/sys/kern/kern_sig.c?r=1.410#964

In other words, if you have asked for floating-point exception traps
via fpsetmask(3) or feeenableexcept(3), then you can't simply defer
or ignore them at the signal level any more than you can defer or
ignore SIGBUS or SIGSEGV.  And if the signal handler returns, it will
restart the instruction and -- if nothing has changed in the set of
trapped floating-point exceptions -- trap again, delivering the same
signal again.

Since we can't lock access to signal dispositions, I don't think we
can guarantee the same effect from userland atomically, but we can
get a close approximation (should be good enough for single-threaded
programs, at least) by mimicking this logic and calling sigqueueinfo
in a loop.

PR misc/56820: Many FPE related tests fail on softfloat machines


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/softfloat/softfloat-specialize

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index