lua-users home
lua-l archive

Re: Can I 'lua_resume' a 'luaL_newstate' and 'lua_close' it as 'LUA_YIELD'?

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


On Sun, May 31, 2020 at 1:20 PM Renato Maia <maia@inf.puc-rio.br> wrote:
>
> Because I'm getting a spurious segmentation fault while handling the
> error in the finalizer in `lua_close`. The example above can reproduce
> the problem with Lua 5.3.5 most of the time in my environment. But I
> was not able to reproduce it with Lua 5.2.4 nor Lua 5.4.0 alpha.
I can confirm this. Here's a minimal reproducer:
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
int main(void) {
 lua_State *L = luaL_newstate();
 luaL_openlibs(L);
 luaL_loadstring(L, "setmetatable({}, { __gc = function()
debug.getinfo(0, 'n') end }); coroutine.yield()");
 lua_resume(L, NULL, 0);
 lua_close(L);
 return 0;
}
I'm not sure, though, whether this is a bug in Lua, or just that
you're not supposed to use lua_resume on the main thread.
Joseph C. Sible

AltStyle によって変換されたページ (->オリジナル) /