Today, When I try to use Lua 5.4.3 ,
CadZinho cannot bootstrap on both windows and linux.
same message:
PANIC: unprotected error in call to Lua API (attempt to index a userdata value)
Lua 5.4.0 runs well on both platform.
Here is a short test case, it will panic when use Buffer method:
`#include <stdio.h>
#include <stdlib.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#ifdef _MSC_VER
#pragma comment(lib, "lua.lib")
#endif
void
setLuaPathBuffer(lua_State* L)
{
luaL_Buffer b;
luaL_buffinit(L, &b);
luaL_addstring(&b, "/etc/init.lua");
lua_getglobal( L, "package");
luaL_pushresult(&b);
lua_setfield( L, -2, "path");
lua_pop( L, 1 );
}
void
setLuaPathString( lua_State* L )
{
lua_getglobal( L, "package" );
lua_pushstring( L, "/etc/init.lua" );
lua_setfield( L, -2, "path" );
lua_pop( L, 1 );
}
int
main(int argc, char** argv)
{
lua_State* L = luaL_newstate();
luaL_openlibs(L);
if (argc == 2 && !strcmp(argv[1],"string")) {
setLuaPathString(L);
} else if (argc == 2 && !strcmp(argv[1],"buffer")) {
setLuaPathBuffer(L);
}
lua_getglobal( L, "package" );
lua_getfield( L, -1, "path" );
const char* cur_path = lua_tostring( L, -1 );
printf("%s\n", cur_path);
lua_close(L);
printf("bye\n");
}
`
best regards.