Re: 2.4, arch-dependent floating point exception and trap handling

Anton Blanchard (anton@samba.org)
Wed, 31 Jul 2002 22:47:15 +1000


Hi,

> I'm seeing discrepancies between the way that floating point
> exceptions are handled on different architectures. Briefly, I have a
> program that uses the glibc function feenableexcept() to enable SIGFPE
> on divide-by-zero errors, then installs a SIGFPE handler that uses
> sigsetjmp/siglongjmp, then divides 1.0 by 0.0 twice.
>
> What I expect to happen is for my signal handler to be called twice.
> What actually happens varies:

...

> my signal handler is called the first time, and then the second
> attempt gets "inf". I've run this under gdb as well; the second SIGFPE is
> not received by the process

The x86 like behaviour happens on ppc64 too:

exceptions enabled: 0
exceptions enabled: 4000000
hello
in handler
abort
a/b=inf
terminating

There is a reason for this. A signal handler might want to do floating
point so exceptions are disabled upon entering a signal handler.

Now the question that needs to be answered is whether sigsetjmp should
save the floating point exception register. I asked our resident
standards expert Chris Yeoh and the answer is no.

So the x86, ppc32 and ppc64 behaviour looks correct.

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