lua-users home
lua-l archive

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


> I am testing a merge of Lua 5.3.3 into Ravi and am facing a strange
> issue which I have not yet been able to debug.
> 
> When I run the Lua tests (_port=1) and enable lua_assert() in the
> code, the following assertion in lcode.c fails when compiling
> math.lua.
> 
> static void freereg (FuncState *fs, int reg) {
>   if (!ISK(reg) && reg >= fs->nactvar) {
>     fs->freereg--;
>     lua_assert(reg == fs->freereg);
>   }
> }
> 
> The assertion failure occurs when compiling math.lua at line 551:
> 
>  assert(1 % math.huge == 1)
> 
> If I comment out this line then the tests pass.
> 
> I have tried running this line standalone and it doesn't cause a failure.
> 
> Obviously I have a modified version of the Lua code and it is likely
> that I have made a mistake somewhere while merging but having scanned
> through the changes several times I cannot locate the bug.
> 
> I have not yet tried to run the Lua tests using unchanged 5.3.3 code -
> I will check that as well.
> 
> Any pointers as to what I should look for? I realize it is impossible
> to comment on modified code base but I thought I shall ask just in
> case there was something obvious I need to check.

That assertion is quite tricky. It ensures that registers are being
allocated-deallocated in a stack discipline, and any optimization
may disturb this fragile balance.

I wouldn't be surprised to find a bug there, but it seems strange that
you get this error and I don't with the same input, since the logic
involved does not seem to vary with "externalities" (such as byte
order, hashings, etc.).


> BTW in the same math.lua script I was puzzled to see that the isNaN
> function always returns true. Is that intentional?

Not at all! That probably was changed for some specific test and
we forgot to change it back.

-- Roberto