summaryrefslogtreecommitdiff
path: root/external/mit
diff options
context:
space:
mode:
authornikita <nikita@NetBSD.org>2023-04-17 20:33:12 +0000
committernikita <nikita@NetBSD.org>2023-04-17 20:33:12 +0000
commit04dbf2b8606395097ac5c6f8911dc76d61845142 (patch)
tree310d5db7101db3319d988c35d5feab2316055bbe /external/mit
parent2a916cac6d6eb7512098c303f5e80b38f6a915a8 (diff)
lua: apply ustream bugfix for "C-stack overflow with deep nesting of coroutine.close."
Diffstat (limited to 'external/mit')
-rw-r--r--external/mit/lua/dist/src/lcorolib.c6
-rw-r--r--external/mit/lua/dist/src/lstate.c5
-rw-r--r--external/mit/lua/dist/src/lua.h4
3 files changed, 8 insertions, 7 deletions
diff --git a/external/mit/lua/dist/src/lcorolib.c b/external/mit/lua/dist/src/lcorolib.c
index a668c8ab405..41458c099e6 100644
--- a/external/mit/lua/dist/src/lcorolib.c
+++ b/external/mit/lua/dist/src/lcorolib.c
@@ -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 @@ static int luaB_auxwrap (lua_State *L) {
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 @@ static int luaB_close (lua_State *L) {
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;
diff --git a/external/mit/lua/dist/src/lstate.c b/external/mit/lua/dist/src/lstate.c
index d3147c3c687..20111e3d55f 100644
--- a/external/mit/lua/dist/src/lstate.c
+++ b/external/mit/lua/dist/src/lstate.c
@@ -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 @@ int luaE_resetthread (lua_State *L, int status) {
}
-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;
diff --git a/external/mit/lua/dist/src/lua.h b/external/mit/lua/dist/src/lua.h
index b6a25de8458..de3ee524888 100644
--- a/external/mit/lua/dist/src/lua.h
+++ b/external/mit/lua/dist/src/lua.h
@@ -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 @@ extern const char lua_ident[];
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);