It was thus said that the Great imzyxwvu@xxxxxxxxx once stated: > > 在 2014年12月14日,17:38,"Sergei Zhirikov" <dmarc-noreply@xxxxxxxxxxxxx> > > (Redacted sender "sfzhi@xxxxxxxxx" for DMARC) 写道: > > > > Back to the point, which is my original email. Please kindly ignore > > everything written after that as irrelevant. However, to avoid any > > further meaningless arguments, here is a modified version of the example > > code, which does not change anything with respect to the segmentation > > fault: > > > > #include <lua.h> > > #include <lualib.h> > > #include <lauxlib.h> > > #include <stdio.h> > > > > int main() > > { > > lua_State *lua = luaL_newstate(); > > luaL_openlibs(lua); > > lua_State *lua2 = lua_newthread(lua); > > luaL_loadstring(lua2, "coroutine.yield()"); > > int res = lua_resume(lua2, 0); > > printf("res=%d, top=%d\n", res, lua_gettop(lua2)); > > lua_pushliteral(lua2, "test"); > > lua_error(lua2); > > return 0; > > } > > Now there is already a main thread lua and a slave thread lua2. The core > of this problem is trying to throw an error on an yielded thread lua2, > whose behavior is *undefined*. No code can be executed on an yielded > thread, so how can there be an error thrown on it? Did you try throwing an > error on lua(which is not yielded) instead of lua2? > > There is no way to throw an error on an yielded thread with pure Lua > code. At least I didn't find one. Sergei is not trying to do that. What he is trying to report is a condition that PUC Lua 5.1 handles: [spc]lucy:/tmp>gcc -o s s.c -llua -lm -ldl [spc]lucy:/tmp>./s res=1, top=0 PANIC: unprotected error in call to Lua API (test) That LuaJIT does not: [spc]lucy:/tmp>gcc -o s s.c -lluajit-5.1 -lm -ldl [spc]lucy:/tmp>./s res=1, top=0 Segmentation fault (core dumped) -spc