lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On 12/06/2014 17:39, Andrew Starks wrote:



On Thu, Jun 12, 2014 at 1:47 PM, Thiago L. <fakedme@gmail.com> wrote:
I was playing around with coroutines and I think I found a bug when interrupting a running coroutine.
(I'm on windows so I'm gonna be using ctrl+c for the interrupt key, so it might not work for everyone)

When doing coroutines:

Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> =coroutine.resume(coroutine.create(function() while true do end end))
[hit ctrl+C here]

When doing pcall:

Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> =pcall(function() while true do end end)
[hit ctrl+C here]
false   interrupted!
>

So is this a bug or am I missing something?


The second case is straightforward. pcall fails because Lua was interrupted.

I believe that this is a case of who is receiving the interrupt. L receives it, and closes L and collects all garbage, including the coroutine, which never *really* closed. The main thread is what is shut down.

I'm probably being imprecise, but that's how i understand it.

-Andrew

It actually waits until the coroutine dies to process the interrupt... and either way it's still a bug...