lua-users home
lua-l archive

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


Hi,

Reporting inconsistency lua_rawgeti() vs lua_getfield() when [t] is light userdata.
Also lua_rawseti().

$ lua -v
Lua 5.2.0 (beta)  Copyright (C) 1994-2011 Lua.org, PUC-Rio
$ uname -a
Darwin iMac-Artur-Galamov.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
$ cc repr.c -llua
$ ./a.out
Segmentation fault
$ cc repr.c -llua -DUSE_PANIC
$ ./a.out
PANIC: unprotected error in call to Lua API (attempt to index a userdata value)
Abort trap
$ 

Lua compiled unchanged with "make macosx; sudo make install".

--- repr.c ---------------------------
#include <lua.h>
#include <lauxlib.h>

int
main(int argc, char *argv[])
{
    lua_State *L;

    L = luaL_newstate();

    lua_pushlightuserdata(L, NULL);

#ifdef USE_PANIC
    lua_getfield(L, -1, "field");
#else // USE_SEGFAULT
    lua_rawseti(L, -1, 1);
#endif

    fprintf(stderr, "not reached\n");
    return 0;
}
--------------------------------------

-- Artur