[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Possible bug in coroutine.resume?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 30 Oct 2013 09:41:17 -0200
> I might be mistaken, but I believe I found a bug in Lua 5.2.2 with
> `coroutine.resume` (even after applying all patches). When calling it
> with the current coroutine (i.e. passing `coroutine.running()`) it
> seems to break the running coroutine. I'm aware that the call itself
> makes no practical sense, but it even returns an appropriate error
> message ("cannot resume non-suspended coroutine") so I don't think
> breaking the state is what it should do. Here's the code to reproduce
> the issue:
>
> ```
> -- Minimal test-case (I think)
> print(coroutine.resume(coroutine.create(function()
> coroutine.resume(coroutine.running())
> coroutine.yield()
> end)))
> -- expected: true
> -- actually: false attempt to yield across a C-call boundary
> ```
>
> Note that even after the call to `coroutine.resume` the coroutine is
> not dead, however: `coroutine.status(coroutine.running())` still
> reports "running".
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.
-- Roberto