lua-users home
lua-l archive

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


I ran the full lua 5.3.3 tests with the latest gcc (6.2.0) and clang
(3.8.0) sanitizers.

Issues that came up were all divisions by zero:

lvm.c:936:11: runtime error: division by zero
Triggered with `1/0`

lvm.c:1016:11: runtime error: division by zero
Triggered with `1//0.0`

lobject.c:109:28: runtime error: division by zero
This is from the test in api.lua `assert(T.testC("arith /; return 1",
2, 0) == 10.0/0)`
Btw, the lack of an accompanying error for arith with LUA_OPIDIV
suggests a missing potential test :)

These all boil down to use of the `luai_numdiv` macro:
#define luai_numdiv(L,a,b)      ((a)/(b))

I guess the fix would be to check for b == 0 before performing the calculation?

On 9 October 2015 at 01:20, Daurnimator <quae@daurnimator.com> wrote:
> On 7 October 2015 at 01:27, Roberto Ierusalimschy
> <roberto@inf.puc-rio.br> wrote:
>>> I compiled lua with the gcc undefined behaviour sanitizer turned on
>>> (-fsanitize=undefined).
>>>
>>>     $ make MYCFLAGS="-fPIC -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_1
>>> -fsanitize=undefined" MYLDFLAGS="-fsanitize=undefined" linux
>>>
>>> Here are the errors I got running test suite:
>>>
>>> [...]
>>
>> Many thanks. BTW, which version of 'clang' are you using? I ran that
>> with clang 3.5, all I got were a few "runtime error: division by zero".
>>
>> -- Roberto
>>
>
> Not clang, gcc 5.2.0.