Re: PROBLEM: Caught SIGFPE exceptions aren't reset



Thank you for your prompt answer. You wrote:


Your handler can do this by masking
exceptions, changing the operands of the failed FP instruction,
or by changing the PC so that the failed instruction is skipped
(your handler may want to emulate the instruction in this case).

Given the current SIGFPE handling in the kernel, a userland handler
CAN'T mask the exceptions or clear the exception flags. This is
demonstrated in my example program where I call both feclearexception
and fedisableexception in the handler. The reason these don't work is
that any change you make to these FPU registers is overwritten with
the saved FPU context on return from the signal handler. Changing the
PC won't help since the exception flag is still set and unmasked on
signal return.

Now either the kernel should clear the corresponding exception flags
or it should present the correct FPU state to the handler for
manipulation. Currently neither of these appear to be the case. So if
there is no problem with the kernel, then the signal man pages should
indicate that while you can catch a SIGFPE, you can't actually return
from it.

If I am completely wrong on this, could you please indicate what kind
of change could be made to the handler in my example program to allow
it to reach the final printf statement in the main program?

Thank you,
Clark Cooper
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Try Finally...
    ... Now we can protect every more or less specialized action ... an error indication (exception or error code) has to be ... an according exception handler can be inserted into the code. ... resources, as they are related to specific actions. ...
    (comp.lang.pascal.delphi.misc)
  • Re: WinForms bug? ThreadException not invoked on Exceptions in system code pre-processing the me
    ... Message Queue and invoking the appropriate handler. ... if an Exception is raised during the PRE-PROCESSING of a Windows ... And because any handling will probably fail if there is no memory, the CLR will terminate the application without attempting to call the ApplicationException or UnhandledException events. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: BackgroungWork taske ended for no appearent reason
    ... To do the same thing with Try/Catch blocks requires wrapping every file access with a Do While ... ... If there was any exception thrown in your DoWork event handler, ... If the operation raises an exception that your code does not handle, ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Frame-based exception handling problem on Server 2008
    ... In this case, the exception ends fatal, usually Cygwin creates a stack ... The Cygwin DLL is a POSIX ... handler is supposed to be *the* exception handler for Cygwin ... It also does not know if the signal handler returns or not. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: PROBLEM: Caught SIGFPE exceptions arent reset
    ... On an i386, you can set a handler for a SIGFPE signal, and after enabling FP ... exceptions with feenableexceptions, ... underlying FP instruction set and its exception model, ... or by changing the PC so that the failed instruction is skipped ...
    (Linux-Kernel)