mirror of
https://github.com/lua/lua.git
synced 2026-01-27 01:44:31 +00:00
Bug: Missing error status in panic function
'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:
parent
9f0c0fe0de
commit
f5e55be2a0
1
ldo.c
1
ldo.c
@ -120,6 +120,7 @@ l_noret luaD_throw (lua_State *L, int errcode) {
|
||||
else { /* thread has no error handler */
|
||||
global_State *g = G(L);
|
||||
errcode = luaE_resetthread(L, errcode); /* close all upvalues */
|
||||
L->status = errcode;
|
||||
if (g->mainthread->errorJmp) { /* main thread has a handler? */
|
||||
setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */
|
||||
luaD_throw(g->mainthread, errcode); /* re-throw in main thread */
|
||||
|
||||
3
ltests.c
3
ltests.c
@ -1655,6 +1655,9 @@ 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("return") {
|
||||
int n = getnum;
|
||||
if (L1 != L) {
|
||||
|
||||
@ -399,6 +399,10 @@ do
|
||||
-- trivial error
|
||||
assert(T.checkpanic("pushstring hi; error") == "hi")
|
||||
|
||||
-- thread status inside panic (bug in 5.4.4)
|
||||
assert(T.checkpanic("pushstring hi; error", "threadstatus; return 2") ==
|
||||
"ERRRUN")
|
||||
|
||||
-- using the stack inside panic
|
||||
assert(T.checkpanic("pushstring hi; error;",
|
||||
[[checkstack 5 XX
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user