Mon Apr 17 20:33:12 2023 UTC ()
lua: apply ustream bugfix for "C-stack overflow with deep nesting of coroutine.close."
(nikita)
diff -r1.8 -r1.9 src/external/mit/lua/dist/src/lcorolib.c
diff -r1.10 -r1.11 src/external/mit/lua/dist/src/lstate.c
diff -r1.12 -r1.13 src/external/mit/lua/dist/src/lua.h
--- src/external/mit/lua/dist/src/lcorolib.c 2023/04/16 20:46:17 1.8
+++ src/external/mit/lua/dist/src/lcorolib.c 2023/04/17 20:33:12 1.9
@@ -1,4 +1,4 @@
-/* $NetBSD: lcorolib.c,v 1.8 2023/04/16 20:46:17 nikita Exp $ */
+/* $NetBSD: lcorolib.c,v 1.9 2023/04/17 20:33:12 nikita Exp $ */
/*
** Id: lcorolib.c
@@ -80,7 +80,7 @@
if (l_unlikely(r < 0)) { /* error? */
int stat = lua_status(co);
if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */
- stat = lua_resetthread(co); /* close its tbc variables */
+ stat = lua_resetthread(co, L); /* close its tbc variables */
lua_assert(stat != LUA_OK);
lua_xmove(co, L, 1); /* move error message to the caller */
}
@@ -176,7 +176,7 @@
int status = auxstatus(L, co);
switch (status) {
case COS_DEAD: case COS_YIELD: {
- status = lua_resetthread(co);
+ status = lua_resetthread(co, L);
if (status == LUA_OK) {
lua_pushboolean(L, 1);
return 1;
--- src/external/mit/lua/dist/src/lstate.c 2023/04/16 20:46:17 1.10
+++ src/external/mit/lua/dist/src/lstate.c 2023/04/17 20:33:12 1.11
@@ -1,4 +1,4 @@
-/* $NetBSD: lstate.c,v 1.10 2023/04/16 20:46:17 nikita Exp $ */
+/* $NetBSD: lstate.c,v 1.11 2023/04/17 20:33:12 nikita Exp $ */
/*
** Id: lstate.c
@@ -347,9 +347,10 @@
}
-LUA_API int lua_resetthread (lua_State *L) {
+LUA_API int lua_resetthread (lua_State *L, lua_State *from) {
int status;
lua_lock(L);
+ L->nCcalls = (from) ? getCcalls(from) : 0;
status = luaE_resetthread(L, L->status);
lua_unlock(L);
return status;
--- src/external/mit/lua/dist/src/lua.h 2023/04/16 20:46:17 1.12
+++ src/external/mit/lua/dist/src/lua.h 2023/04/17 20:33:12 1.13
@@ -1,4 +1,4 @@
-/* $NetBSD: lua.h,v 1.12 2023/04/16 20:46:17 nikita Exp $ */
+/* $NetBSD: lua.h,v 1.13 2023/04/17 20:33:12 nikita Exp $ */
/*
** Id: lua.h
@@ -157,7 +157,7 @@
LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
LUA_API void (lua_close) (lua_State *L);
LUA_API lua_State *(lua_newthread) (lua_State *L);
-LUA_API int (lua_resetthread) (lua_State *L);
+LUA_API int (lua_resetthread) (lua_State *L, lua_State *from);
LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);