[petsc-dev] Preserving floating point exception flags

Jed Brown jed at 59A2.org
Mon May 3 14:18:16 CDT 2010


I made some updates for floating point trapping, -fp_trap should now
work on GNU systems and x86/64 systems (if xmmintrin.h is available).
But unfortunately the exception flags have been cleared by the time the
signal handler is invoked, which makes it impossible for the handler to
say what kind of exception occurred.  This is on Linux 2.6.33, I'm
curious if the flags are reset on other architectures.  Also, does
anyone here know if there is a way to prevent the kernel (or maybe libc)
from resetting the flags before invoking the signal handler?

In lieu of that, you can always pass -fp_trap and run in a debugger.  It
will break when the exception occurs and you can check the flags with
fetestexcept(FE_ALL_EXCEPT), see fenv.h for the enum values (probably
/usr/include/bits/fenv.h).

Jed



More information about the petsc-dev mailing list