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.
This commit is contained in:
Roberto Ierusalimschy
2025-01-16 16:07:39 -03:00
parent 2d8d5c74b5
commit 664bda02ba
3 changed files with 28 additions and 2 deletions

View File

@@ -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) {