lua-users home
lua-l archive

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


As I mentioned in an email some time ago, I'm trying to port Lua 5.1 to a certain C compiler (the one available in the Go language's toolchain). I've had some success in that (curiously, it requires me to also port big parts of C standard library...), and I'm gradually adding tests from "the Lua testsuite" and fixing some bugs, but since some time ago, I'm stuck at one place and I have trouble pushing forward.

The line where I have problem is:
    f = loadstring[[ return {...} ]]
in "vararg.lua", and the stacktrace I'm getting (somewhat edited for clarity) is like below:

lparser.c:374 (0x457e99)
    close_func: lua_assert(luaG_checkcode(f));
lparser.c:393 (0x4580ad)
    luaY_parser: close_func(&lexstate);
ldo.c:497 (0x44be85)
    f_parser: tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
golua_impl.c:21 (0x43afe6)  /* three frames below are a custom LUAI_TRY */
    akavel.com/go-lua/internal.golua_call: (*f)(L, ud);
golua_stdlib.go:32 (0x4374a1)
    akavel.com/go-lua/internal.go_try: golua_call(L, f, uv)
golua_impl.c:16 (0x43af9e)
    _luai_try: ·go_try((uintptr)L, (uintptr)f, (uintptr)ud);
ldo.c:118 (0x44a61e)
    luaD_rawrunprotected: );
ldo.c:463 (0x44bd17)
    luaD_pcall: status = luaD_rawrunprotected(L, func, u);
ldo.c:513 (0x44c03e)
    luaD_protectedparser: status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
lapi.c:876 (0x43ebdc)
    lua_load: status = luaD_protectedparser(L, &z, chunkname);
lauxlib.c:615 (0x44108a)
    luaL_loadbuffer: return lua_load(L, getS, &ls, name);
lbaselib.c:281 (0x4422a8)
    luaB_loadstring: return load_aux(L, luaL_loadbuffer(L, s, l, chunkname));
ldo.c:319 (0x44b4f2)
    luaD_precall: n = (*curr_func(L)->c.f)(L);  /* do the actual call */
lvm.c:599 (0x4672e7)
    luaV_execute: return;  /* yield */
ldo.c:377 (0x44b7ed)
    luaD_call: luaV_execute(L, 1);  /* call it */
lapi.c:807 (0x43e9be)
    f_call: luaD_call(L, c->func, c->nresults);
golua_impl.c:21 (0x43afe6)  /* three frames below are a custom LUAI_TRY */
    go-lua/internal.golua_call: (*f)(L, ud);
golua_stdlib.go:32 (0x4374a1)
    go-lua/internal.go_try: golua_call(L, f, uv)
golua_impl.c:16 (0x43af9e)
    _luai_try: ·go_try((uintptr)L, (uintptr)f, (uintptr)ud);
ldo.c:118 (0x44a61e)
    luaD_rawrunprotected: );
ldo.c:463 (0x44bd17)
    luaD_pcall: status = luaD_rawrunprotected(L, func, u);
lapi.c:828 (0x43eab7)
    lua_pcall: status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
golua_wrappers.c:49 (0x43b23b)
    go-lua/internal.lua_pcall: ret = (uintptr) lua_pcall((lua_State*)L, (int)nargs, (int)nresults, (int)errfunc);
golua_wrappers.go:38 (0x437778)
    go-lua/internal.State.Pcall: return int(lua_pcall(uintptr(L), uintptr(nargs), uintptr(nresults), uintptr(errfunc)))
suite_test.go:56 (0x4395f6)
    go-lua/internal.func.003: r = l.Pcall(0, 0, 0)

The problem manifests in the same way when I just call "luaL_loadbuffer()" with string " return {...} " as code.

Would anybody have any suggestion as to what I could check more? Should I maybe dump memory from "f->code" up to "f->code + f->sizecode - 1" and try to compare with what I'd see in the reference Lua implementation for the same snippet of code, i.e. luaL_loadbuffer() with " return {...} "?

I'd be grateful for any help!
Thanks,
/Mateusz Czapliński.