Re: An assertion is triggered in the luaG_runerror()

Sergey Bronnikov <[email protected]> Fri, 15 May 2026 07:09:04 -0700 (PDT)
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
Hello,

the behavior also can be reproduced by the following chunk (select.lua):

```
local function fn()
    return function(...)
        local n = select("#", ...)
        assert(n == 1, tostring(n))
    end
end

local f = fn()
f(1)
```

make -j "MYCFLAGS=-DLUAI_ASSERT"
./lua select.lua 
./lua: select.lua:4: 0
stack traceback:
        [C]: in global 'assert'
        select.lua:4: in local 'f'
        select.lua:9: in main chunk
        [C]: in ?

Reverting the commit 36c1f6d solves the issue.

Sergey

On Tuesday, May 12, 2026 at 10:56:57 PM UTC+3 Roberto Ierusalimschy wrote:

> > an assertion is triggered on execution of a Lua chunk below:
> > 
> > ./lua -e "
> > > local obj = setmetatable({}, {
> > __index = function(l, ...)
> > local _ = l > 1
> > end
> > })
> > obj:method();
> > > "
> > lua: ldebug.c:865: void luaG_runerror(lua_State *, const char *, ...): 
> > Assertion `(((((&((ci)->func.p)->val)))->tt_) == (((((6) | ((0) << 4))) 
> | 
> > (1 << 6))))' failed.
> > Aborted (core dumped)
>
> Thanks for the feedback. Indeed, the commit 36c1f6d was wrong:
> Although OP_VARARGPREP does not need to be preceded by an "OT"
> instruction (it is never preceded by any instruction), it does need
> a correct L->top to work properly. (The comment in lopcodes.h:420
> is misleading.)
>
> -- Roberto
>

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/7a9d7753-efc3-4cd6-a878-4b5920d212cen%40googlegroups.com.