chunkname is seemingly ignored when loading bytecode

99 views
Skip to first unread message

Sainan

unread,
May 30, 2025, 6:23:59 PMMay 30
to lu...@googlegroups.com
It seems like the semantic is to copy verbatim the path that was passed to luac or ? when -s was passed, which seems kind of unexpected to me.

Like, on one hand I understand that debug info is somewhat unrelated from 'chunkname', but e.g. in the case of stripped debug info, the chunkname could be used in place of the '?'. Like, looking at loadFunction, it seems like this is vaguely what it already supports:

if (f->source == NULL) /* no source in dump? */
f->source = psource; /* reuse parent's source */

but then at luaU_undump, the 'psource' parameter is set to NULL for the main function:

loadFunction(&S, cl->p, NULL);

Of course, this also looks wholly different on the main branch now so I'm not sure if this is even still an issue in Lua 5.5?

-- Sainan

Sainan

unread,
Jun 1, 2025, 3:52:01 PMJun 1
to lu...@googlegroups.com
Hmm, yeah, just compiled Lua @ master and it does seem to still be a problem; this code:

load(string.dump(function() error() end, true), "chunkname")()

produces this error:

lua: (error object is a nil value)
stack traceback:
[C]: in field 'error'
?: in function <?:1>
test.lua:1: in main chunk
[C]: in ?

Note the ? and ?:1 instead of using chunkname.

-- Sainan

blog...@gmail.com

unread,
Jun 2, 2025, 6:01:52 PMJun 2
to lua-l
Test all lua from 5.1 to 5.5


5.1 5.2 5.3 5.4  from Debain Sid, 5.5 from git

воскресенье, 1 июня 2025 г. в 22:52:01 UTC+3, Sainan:
Reply all
Reply to author
Forward
0 new messages