Source-Changes-HG archive

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

[src/trunk]: src/external/mit/lua/dist/src lua: apply ustream bugfix for "C-s...



details:   https://anonhg.NetBSD.org/src/rev/c2dc9f2ca35d
branches:  trunk
changeset: 374302:c2dc9f2ca35d
user:      nikita <nikita%NetBSD.org@localhost>
date:      Mon Apr 17 20:33:12 2023 +0000

description:
lua: apply ustream bugfix for "C-stack overflow with deep nesting of coroutine.close."

diffstat:

 external/mit/lua/dist/src/lcorolib.c |  6 +++---
 external/mit/lua/dist/src/lstate.c   |  5 +++--
 external/mit/lua/dist/src/lua.h      |  4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diffs (66 lines):

diff -r b577658937c4 -r c2dc9f2ca35d external/mit/lua/dist/src/lcorolib.c
--- a/external/mit/lua/dist/src/lcorolib.c      Mon Apr 17 20:27:40 2023 +0000
+++ b/external/mit/lua/dist/src/lcorolib.c      Mon Apr 17 20:33:12 2023 +0000
@@ -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 -r b577658937c4 -r c2dc9f2ca35d external/mit/lua/dist/src/lstate.c
--- a/external/mit/lua/dist/src/lstate.c        Mon Apr 17 20:27:40 2023 +0000
+++ b/external/mit/lua/dist/src/lstate.c        Mon Apr 17 20:33:12 2023 +0000
@@ -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 
 }
 
 
-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 -r b577658937c4 -r c2dc9f2ca35d external/mit/lua/dist/src/lua.h
--- a/external/mit/lua/dist/src/lua.h   Mon Apr 17 20:27:40 2023 +0000
+++ b/external/mit/lua/dist/src/lua.h   Mon Apr 17 20:33:12 2023 +0000
@@ -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);
 



Home | Main Index | Thread Index | Old Index