This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Is it possible to preserve flags for fetestexcept() insidesignal handler


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 [1].
> 
> 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?
> 
> 
> [1] 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
you want.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]