diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-11-08 11:55:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-11-08 11:55:25 -0300 |
commit | bfbff3703edae789fa5efa9bf174f8e7cff4ded8 (patch) | |
tree | 5e8466f78f52b5d53691f800354a3aed313d11a9 /lstate.c | |
parent | 74d99057a5146755e737c479850f87fd0e3b6868 (diff) | |
download | lua-bfbff3703edae789fa5efa9bf174f8e7cff4ded8.tar.gz lua-bfbff3703edae789fa5efa9bf174f8e7cff4ded8.tar.bz2 lua-bfbff3703edae789fa5efa9bf174f8e7cff4ded8.zip |
Bug: Wrong status in coroutine during reset
When closing variables during 'coroutine.close' or 'lua_resetthread',
the status of a coroutine must be set to LUA_OK; a coroutine should
not run with any other status. (See assertion in 'lua_callk'.)
After the reset, the status should be kept as normal, as any error
was already reported.
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -166,7 +166,7 @@ void luaE_checkcstack (lua_State *L) { | |||
166 | if (getCcalls(L) == LUAI_MAXCCALLS) | 166 | if (getCcalls(L) == LUAI_MAXCCALLS) |
167 | luaG_runerror(L, "C stack overflow"); | 167 | luaG_runerror(L, "C stack overflow"); |
168 | else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11)) | 168 | else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11)) |
169 | luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ | 169 | luaD_throw(L, LUA_ERRERR); /* error while handling stack error */ |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
@@ -330,13 +330,13 @@ int luaE_resetthread (lua_State *L, int status) { | |||
330 | ci->callstatus = CIST_C; | 330 | ci->callstatus = CIST_C; |
331 | if (status == LUA_YIELD) | 331 | if (status == LUA_YIELD) |
332 | status = LUA_OK; | 332 | status = LUA_OK; |
333 | L->status = LUA_OK; /* so it can run __close metamethods */ | ||
333 | status = luaD_closeprotected(L, 1, status); | 334 | status = luaD_closeprotected(L, 1, status); |
334 | if (status != LUA_OK) /* errors? */ | 335 | if (status != LUA_OK) /* errors? */ |
335 | luaD_seterrorobj(L, status, L->stack + 1); | 336 | luaD_seterrorobj(L, status, L->stack + 1); |
336 | else | 337 | else |
337 | L->top = L->stack + 1; | 338 | L->top = L->stack + 1; |
338 | ci->top = L->top + LUA_MINSTACK; | 339 | ci->top = L->top + LUA_MINSTACK; |
339 | L->status = cast_byte(status); | ||
340 | luaD_reallocstack(L, cast_int(ci->top - L->stack), 0); | 340 | luaD_reallocstack(L, cast_int(ci->top - L->stack), 0); |
341 | return status; | 341 | return status; |
342 | } | 342 | } |