[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: potentially incorrect assert in luaV_execute
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 15 Feb 2022 08:33:49 -0300
> There are several asserts that compare against L->stack_last in different
> parts of lua.
>
> In luaV_execute there is this assert on line 1162
>
> lua_assert(base <= L->top && L->top < L->stack_last);
>
> [...]
>
> I believe the assert in luaV_execute should be `lua_assert(base <= L->top
> && L->top <= L->stack_last);`
Thanks for the feedback. You are right. Independently of specific cases,
there is nothing wrong with L->top == L->stack_last. The top element
is always at L->top - 1; when the stack is full, that translates to
L->stack_last - 1, which is the last element of the array. (The name
'stack_last' is a bit confusing, but a comment clearly states that it
represents "last element + 1".)
-- Roberto