aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-05-09 11:13:45 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-05-09 11:13:45 -0300
commit389116d8abcc96db3cfe2f3cc25789c089fe12d6 (patch)
treef3d07b50c17f28ba09cf547d5a67519ffe3271a4 /ldo.c
parent01bded3d8cd88a2d7f472b45f706565f1a9ef3b1 (diff)
downloadlua-389116d8abcc96db3cfe2f3cc25789c089fe12d6.tar.gz
lua-389116d8abcc96db3cfe2f3cc25789c089fe12d6.tar.bz2
lua-389116d8abcc96db3cfe2f3cc25789c089fe12d6.zip
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.
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c4
1 files changed, 1 insertions, 3 deletions
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,
686 if (likely(!errorstatus(status))) 686 if (likely(!errorstatus(status)))
687 lua_assert(status == L->status); /* normal end or yield */ 687 lua_assert(status == L->status); /* normal end or yield */
688 else { /* unrecoverable error */ 688 else { /* unrecoverable error */
689 status = luaF_close(L, L->stack, status); /* close all upvalues */
690 L->status = cast_byte(status); /* mark thread as 'dead' */ 689 L->status = cast_byte(status); /* mark thread as 'dead' */
691 luaD_seterrorobj(L, status, L->stack + 1); /* push error message */ 690 luaD_seterrorobj(L, status, L->top); /* push error message */
692 L->ci = &L->base_ci; /* back to the original C level */
693 L->ci->top = L->top; 691 L->ci->top = L->top;
694 } 692 }
695 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield 693 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield