Re: Is LuaJIT intended to be FPU exception safe?

  • From: Mike Pall <mike-1209@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 5 Sep 2012 19:42:56 +0200

Niklas Frykholm wrote:
> Is LuaJIT intended to be FPU exception safe, and this exception a bug in 
> LuaJIT?

FPU exceptions must NOT be enabled. BTW: The same is true for Lua.

> Or is LuaJIT not intended to be FPU exception safe? Meaning that I
> should disable FPU exceptions whenever I call into LuaJIT.

Actually, you're violating C99, IEEE-754 and the x86 and x64 ABIs.
(all at the same time :-) ). You must not enable FP exceptions
globally, because any external C function (or library) can expect
to operate with exceptions disabled. You'll get weird crashes all
over the place if you violate this constraint.

> (With the
> unfortunate consequence that I have no way of detecting floating point
> errors in users' scripts.)

That is a non-workable approach. First, x87 doesn't cut it, since
there's SSE, too. Second, your definition of "errors in users'
scripts" is probably flawed. E.g. infinities or denormals can
occur in many scientific computations and they have a proper use.

--Mike

Other related posts: