lua-users home
lua-l archive

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


The original problem occurs on modified 5.2.1, the same behaviour can be reproduced on 5.3.1

2015-11-07 21:17 GMT+01:00 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
> I use Lua in some embedded device and I have found some mysterious restart
> records in log.
> I dig into the problem and I discover this error mechanics:
> -ftrapv in C_FLAGS
> LUA_NUMBER int
>
> Lua code: local n = 12345678901234567890
> My function strtod used by parser returns LUA_MININTEGER without signaling
> an error through endptr.
> Then function luaH_getint is invoked from assignment with key =
> LUA_MININTEGER

Would you be so nice as to tell us what version of Lua you are talking
about?


Anyway, this problem has been already reported in Lua 5.3 [1]. I guess
the best fix is this ene, which achieves the original intention of the
code:

-  if (l_castS2U(key - 1) < t->sizearray)
+  if (l_castS2U(key) - 1 < t->sizearray)

There are a few other problems detected with -ftrapv. They are all easily
fixed (and will be fixed in our next release).

[1] http://lua-users.org/lists/lua-l/2015-10/msg00069.html

-- Roberto