Floating point exception on x64

  • From: Shmuel Zeigerman <shmuz@xxxxxxxxxx>
  • To: LuaJIT list <luajit@xxxxxxxxxxxxx>
  • Date: Sat, 10 Jun 2017 20:16:08 +0300

Hello,

There is an application that allows user-written plugins.
There are 2 plugins, let's call them PlugLua (mine) and PlugPascal (somebody's).
Plugins written in Pascal modify FPU control word allowing FP exceptions.
Lua plugins don't like it but I managed to solve it by calling _control87(_MCW_EM,_MCW_EM) in a few key points.

However recently I got a bug report about crash on calling math.log10(0) in PlugLua.
*  exception does not occur if PlugPascal is not present
* _control87(_MCW_EM,_MCW_EM) does not help in this case
*  executing division by zero does not trigger exception
*  there is no exception on 32 bit platform, it occurs only on x64
* exception occurs if PlugLua uses LuaJIT 2.0.5, it does not occur with LuaJIT 2.1 beta 3 or Lua 5.1

I'm going to change to LuaJIT 2.1 beta 3 but could somebody explain what happens? (My knowledge is far from being able to understand that).

Thanks.

--
Shmuel


Other related posts: