diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-01-16 16:07:39 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-01-16 16:07:39 -0300 |
commit | 664bda02ba4bd167728a2acbe658cc4a9dd9b0b5 (patch) | |
tree | fc6fe196de8326e2eee3deb81e448525a362afa8 /ltests.c | |
parent | 2d8d5c74b5ef3d333314feede0165df7c3d13811 (diff) | |
download | lua-664bda02ba4bd167728a2acbe658cc4a9dd9b0b5.tar.gz lua-664bda02ba4bd167728a2acbe658cc4a9dd9b0b5.tar.bz2 lua-664bda02ba4bd167728a2acbe658cc4a9dd9b0b5.zip |
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.
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1367,7 +1367,7 @@ static int checkpanic (lua_State *L) { | |||
1367 | b.L = L; | 1367 | b.L = L; |
1368 | L1 = lua_newstate(f, ud, 0); /* create new state */ | 1368 | L1 = lua_newstate(f, ud, 0); /* create new state */ |
1369 | if (L1 == NULL) { /* error? */ | 1369 | if (L1 == NULL) { /* error? */ |
1370 | lua_pushnil(L); | 1370 | lua_pushstring(L, MEMERRMSG); |
1371 | return 1; | 1371 | return 1; |
1372 | } | 1372 | } |
1373 | lua_atpanic(L1, panicback); /* set its panic function */ | 1373 | 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) { | |||
1507 | 1507 | ||
1508 | 1508 | ||
1509 | static const char *const statcodes[] = {"OK", "YIELD", "ERRRUN", | 1509 | static const char *const statcodes[] = {"OK", "YIELD", "ERRRUN", |
1510 | "ERRSYNTAX", MEMERRMSG, "ERRGCMM", "ERRERR"}; | 1510 | "ERRSYNTAX", MEMERRMSG, "ERRERR"}; |
1511 | 1511 | ||
1512 | /* | 1512 | /* |
1513 | ** Avoid these stat codes from being collected, to avoid possible | 1513 | ** 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) { | |||
1806 | int level = getnum; | 1806 | int level = getnum; |
1807 | luaL_traceback(L1, L1, msg, level); | 1807 | luaL_traceback(L1, L1, msg, level); |
1808 | } | 1808 | } |
1809 | else if EQ("threadstatus") { | ||
1810 | lua_pushstring(L1, statcodes[lua_status(L1)]); | ||
1811 | } | ||
1812 | else if EQ("alloccount") { | ||
1813 | l_memcontrol.countlimit = cast_uint(getnum); | ||
1814 | } | ||
1809 | else if EQ("return") { | 1815 | else if EQ("return") { |
1810 | int n = getnum; | 1816 | int n = getnum; |
1811 | if (L1 != L) { | 1817 | if (L1 != L) { |