From 389116d8abcc96db3cfe2f3cc25789c089fe12d6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 9 May 2019 11:13:45 -0300 Subject: Coroutines do not unwind the stack in case of errors Back to how it was, a coroutine does not unwind its stack in case of errors (and therefore do not close its to-be-closed variables). This allows the stack to be examined after the error. The program can use 'coroutine.kill' to close the variables. The function created by 'coroutine.wrap', however, closes the coroutine's variables in case of errors, as it is impossible to examine the stack any way. --- ldo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'ldo.c') diff --git a/ldo.c b/ldo.c index 2a98c397..d474c0a0 100644 --- a/ldo.c +++ b/ldo.c @@ -686,10 +686,8 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, if (likely(!errorstatus(status))) lua_assert(status == L->status); /* normal end or yield */ else { /* unrecoverable error */ - status = luaF_close(L, L->stack, status); /* close all upvalues */ L->status = cast_byte(status); /* mark thread as 'dead' */ - luaD_seterrorobj(L, status, L->stack + 1); /* push error message */ - L->ci = &L->base_ci; /* back to the original C level */ + luaD_seterrorobj(L, status, L->top); /* push error message */ L->ci->top = L->top; } *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield -- cgit v1.2.3-55-g6feb