lua-users home
lua-l archive

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

Hello Alexander,

Just a wild guess based on a weird traceback I saw in your example and the data I read in issue. (Unfortunately I do not have time to analyze LuaAlchemy sources.)

When you register as -> lua callback (I assume) you store not only passed lua function, but also a lua_State and then call stored callback in that lua_State.
But the problem arises when you register as->lua callbacks from coroutines because you store _that_ coroutine and then call stored callback in _that_ coroutine's lua_State. So you are trying to resume coroutine from the coroutine itself.


On Sun, Feb 15, 2009 at 3:02 PM, Alexander Gladysh <> wrote:
On Sat, Feb 14, 2009 at 10:56 PM, Alexander Gladysh <> wrote:
>>>      local coro -- A forward declaration
>>>      coro = coroutine.create(function()
>>>        ENGINE.call_me_later(function() assert(coroutine.resume(coro)) end)
>>>        coroutine.yield()
>>>      end)
>>>      assert(coroutine.resume(coro))
>>> When I run it, coroutine.resume() inside the callback fails with
>>> message "cannot resume running coroutine". Coroutine status is
>>> "running" and coroutine.running() points to the coroutine as well.
>> It seems like ENGINE.call_me_later() is executing the function that it is
>> being passed before returning, so it gets run in the context of the coro
>> coroutine itself, which obviously cannot be resumed because it is not
>> suspended. I freely admit I may be misunderstanding something here though.
> No, I just double checked by adding extensive logging, callback gets
> called after whole main chunk is executed.

Actually I can not even imagine what may trigger such behaviour...
Does anyone have any advice on how to debug this?

This bug is with Lua Alchemy 0.2. It is filed here:

To reproduce it, paste the code from the issue into the Lua Alchemy demo:

Unfortunately all callback error handling is going to Flash log, so
you have to be running under debug Flash. A workaround is to replace

print = as3.makeprinter(output)

and replace asserts with code to print errors (also any as3.trace()
calls to calls to print()).

Any ideas are welcome!