[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Integer overflow catched by -ftrapv compiler flag
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sat, 7 Nov 2015 18:17:30 -0200
> 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