From 664bda02ba4bd167728a2acbe658cc4a9dd9b0b5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 16 Jan 2025 16:07:39 -0300 Subject: fixing 'lua_status' in panic. 'luaD_throw' may call 'luaE_resetthread', which returns an error code but clears 'L->status'; so, 'luaD_throw' should set that status again. --- ltests.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ltests.c') diff --git a/ltests.c b/ltests.c index 6c77703c..83d08ac8 100644 --- a/ltests.c +++ b/ltests.c @@ -1367,7 +1367,7 @@ static int checkpanic (lua_State *L) { b.L = L; L1 = lua_newstate(f, ud, 0); /* create new state */ if (L1 == NULL) { /* error? */ - lua_pushnil(L); + lua_pushstring(L, MEMERRMSG); return 1; } lua_atpanic(L1, panicback); /* set its panic function */ @@ -1507,7 +1507,7 @@ static int getindex_aux (lua_State *L, lua_State *L1, const char **pc) { static const char *const statcodes[] = {"OK", "YIELD", "ERRRUN", - "ERRSYNTAX", MEMERRMSG, "ERRGCMM", "ERRERR"}; + "ERRSYNTAX", MEMERRMSG, "ERRERR"}; /* ** Avoid these stat codes from being collected, to avoid possible @@ -1806,6 +1806,12 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { int level = getnum; luaL_traceback(L1, L1, msg, level); } + else if EQ("threadstatus") { + lua_pushstring(L1, statcodes[lua_status(L1)]); + } + else if EQ("alloccount") { + l_memcontrol.countlimit = cast_uint(getnum); + } else if EQ("return") { int n = getnum; if (L1 != L) { -- cgit v1.2.3-55-g6feb