lua-users home
lua-l archive

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


Simular problem here, our code passes registry index to luaL_checkxxx
and failed on LJ2. The following code snippet segfaults on the "printf"
line with LJ2 on debian 5.0.

#include <stdio.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"

int cfunc(lua_State *L)
{
printf("checkstring for upvalue 2 %s\n", luaL_checkstring(L,
lua_upvalueindex(1)));
return 0;
}

int main()
{
lua_State *L = lua_open();
luaopen_base(L);
lua_pushstring(L, "aaa");
lua_pushcclosure(L, cfunc, 1);
lua_call(L, 0, 0);
}



Regards
Long

Mike Pall 写道:
> I wrote:
>   
>> Currently LJ2 happily misinterprets negative indexes for these
>> functions. Sooo ... what to do? I guess I'll have to bite the
>> bullet and support some undefined behavior, too. :-/
>>
>> Patch will follow shortly.
>>     
>
> Ok, here it is. Timm, can you please check whether this fixes
> your original problem? Thank you!
>
> --Mike
>