[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Possible bug in coroutine.resume?
- From: Florian Nücke <florian@...>
- Date: Wed, 30 Oct 2013 18:32:22 +0100
Bug confirmed. I guess the problem is this line when finishing
'lua_resume' (file ldo.c):
L->nny = 1; /* do not allow yields */
(It assumed to coroutine was not running before the call to resume,
so it restores its original status; but in your example the original
status was not "do not allow yields".) But I have to check it.
Indeed. Storing and restoring the previous value works:
```
ldo.c:
@@ -526,9 +526,10 @@ static void resume (lua_State *L, void *ud) {
LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) {
- int status;
+ int status, nny;
lua_lock(L);
luai_userstateresume(L, nargs);
+ nny = L->nny;
L->nCcalls = (from) ? from->nCcalls + 1 : 1;
L->nny = 0; /* allow yields */
api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
@@ -548,7 +549,7 @@ LUA_API int lua_resume (lua_State *L, lua_State
*from, int nargs) {
}
lua_assert(status == L->status);
}
- L->nny = 1; /* do not allow yields */
+ L->nny = nny; /* restore yield permission */
L->nCcalls--;
lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0));
lua_unlock(L);
```
Unless I'm missing something. At least the basic tests from the test
suite all still pass.
-- Roberto
Florian