lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Saurabh T wrote:
  This is with Lua 5.1.2. If in one's C code, SIGFPEs are enabled for invalid floating point operations (with fpsetmask(FP_X_INV) or feenableexcept(FE_INVALID) or ... depending on platform), a Lua script run using an app built on that C code throws an arithmetic exception when it uses numbers larger than INT_MAX. This is because Lua tries to stick the number into an int first. This happens in lua_number2int(k,n) with the following stack trace:

[1] luaH_get line 476 in "ltable.c"
[2] luaH_set line 495 in "ltable.c"
[3] addk line 231 in "lcode.c"
[4] luaK_numberK line 260 in "lcode.c"
[5] discharge2reg line 359 in "lcode.c"
[6] exp2reg line 391 in "lcode.c"
[7] luaK_exp2nextreg line 418 in "lcode.c"
[8] luaK_exp2anyreg line 431 in "lcode.c"
[9] luaK_storevar line 485 in "lcode.c"
[10] assignment line 954 in "lparser.c"

This seems to happen when the Lua script is parsed, before anything is executed, so perhaps Lua
needs to set those exceptions off when it begins parsing and revert their state when it finishes
parsing. Thanks.

The thread [1] seems to be related.

[1] http://lua-users.org/lists/lua-l/2009-03/threads.html#00320

--
Shmuel