lua-users home
lua-l archive

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


> If you compile plain Lua with API checks (i.e. -DLUA_USE_APICHECK),
> you'll get a similar assertion (I just tried).

I think that is going to be my default development mode for Lua since now.:-)

> You may want to re-read sections 3.1 and 3.2 of the Lua manual.
> These define what an "acceptable" and what a "valid" index is.
> Crude ASCII diagram follows:

>          stack base     stack top           stack max
>          V              V                   V
> ... -7 -6|-5 -4 -3 -2 -1|                   |
>          |## ## ## ## ##|                   |
>          |+1 +2 +3 +4 +5|+6 +7 +8 +9 ... +20|+21 +22 ...
>           \------------/
>            valid indexes
>           \--------------------------------/
>                   acceptable indexes

The section 3.2 defines acceptable indices as:

     (index < 0 && abs(index) <= top) ||
     (index > 0 && index <= stackspace)

Cutting positive indices on 'stackspace' and negative on 'top' looks pretty peculiar for me.
Thanks for noting that!

>> So, I suppose I'm doing a legal thing trying to fetch a value at
>> the end (-1) without checking a stack size. Probably, it's not a
>> big deal, and LuaJIT will still work fine with suppressed
>> assertions, but I really like this mode to make sure I do
>> everything right.

> No, it's not safe to do this. Suppressing the assertion just hides
> that it's accessing potentially random memory locations.

I agree with that too.

Finally, LuaJIT has been integrated into my system. It's time to give it a good kick under high load!

Be well,
Seny