This is the mail archive of the
mailing list for the glibc project.
Re: Is it possible to preserve flags for fetestexcept() insidesignal handler
- From: Carlos O'Donell <carlos at systemhalted dot org>
- To: Jed Brown <jed at 59A2 dot org>
- Cc: libc-help at sourceware dot org
- Date: Thu, 7 Jun 2012 13:54:51 -0400
- Subject: Re: Is it possible to preserve flags for fetestexcept() insidesignal handler
- References: <CAM9tzSm0LsUnvxEbkcaOX_akXFQE2xodfsh0Ph=+wU-Hi-Wm_A@mail.gmail.com>
On Thu, May 31, 2012 at 06:28:56PM -0500, Jed Brown wrote:
> As a debugging aid, I use feenableexcept() and set a signal handler
> that provides a trace. Unfortunately, calling fetestexcept() inside
> the signal handler shows all flags unset so there is no way for the
> user to know what kind of floating point exception occurred. The best
> I've managed is to give the user directions for running the program in
> gdb, how to call fetestexcept() themselves once the error has trapped,
> and how to interpret the results .
> Is this the best I can do or is there some way to make fetestexcept()
> return the correct flags when called from the signal handler? Does the
> kernel reset them unconditionally?
>  This especially sucks because the numeric codes are a lot to
> remember and the macros aren't visible to GDB; I should write a
> utility function to be called from the debugger.
You must not call fetestexcept() from a signal handler since it is
not async-signal safe.
Unfortunately there isn't any infrastructure in glibc to do what