bennyxqg / lua-alchemy

Automatically exported from code.google.com/p/lua-alchemy
0 stars 0 forks source link

"dirty state stack" error when resuming a coroutine from AS3 callback #116

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I'm using a coroutine wrapper to allow scripts to wait for events with
coroutine.yield and event listeners, using the following wrapper code:

local run = coroutine.create( function( )
    local threadTaskID = as3.tolua(taskID)

    waiting_threads[ threadTaskID ] = coroutine.running()

    -- Set the running_thread variable so functions calls that communicate
with the hypervisor core
    -- can provide it as a reference
    running_thread = threadTaskID

    --%%SCRIPT%%--
    waiting_threads[ threadTaskID ] = nil
    controller.taskComplete( threadTaskID ) 
end)

The --%%SCRIPT%%-- text is replaced with the body of the task script I want.

The first task, is always executed flawlessly. The second task complains
about a "dirty state stack".

I *think* that this is because of the "controller.taskComplete(
threadTaskID )" call that I make to notify the AIR application that the
task was completely...since that goes into As3 and a sequence of further
calls come back to the lua engine, I think the current state is the state
of the coroutine that just called "taskComplete()", and so is causing this
error.

Simply returning data isn't going to work here, since this is within a
coroutine that's resumed after the main script has terminated. (So it makes
sense in a weird way that I'm getting a "dirty state stack" error.)

Does anyone have any suggestions for a workaround?

Original issue reported on code.google.com by sh0rtw...@gmail.com on 5 Mar 2009 at 4:26

GoogleCodeExporter commented 9 years ago

Original comment by aglad...@gmail.com on 5 Mar 2009 at 8:34

GoogleCodeExporter commented 9 years ago
Can you provide a minimal working example to reproduce this bug?

Original comment by aglad...@gmail.com on 5 Mar 2009 at 8:37

GoogleCodeExporter commented 9 years ago
The attached application demonstrates this behaviour.

Original comment by sh0rtw...@gmail.com on 10 Mar 2009 at 10:04

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you! I'll try to deal with this issue on this week.

Original comment by aglad...@gmail.com on 10 Mar 2009 at 10:38

GoogleCodeExporter commented 9 years ago

Original comment by aglad...@gmail.com on 10 Mar 2009 at 10:38

GoogleCodeExporter commented 9 years ago
I'm here, but I still have to look into this issue, sorry. Will try to deal 
with it ASAP.

Alexander.

Original comment by aglad...@gmail.com on 16 Mar 2009 at 12:01

GoogleCodeExporter commented 9 years ago

Original comment by aglad...@gmail.com on 21 Sep 2009 at 5:04

GoogleCodeExporter commented 9 years ago

Original comment by aglad...@gmail.com on 21 Sep 2009 at 5:04

GoogleCodeExporter commented 9 years ago

Original comment by aglad...@gmail.com on 11 May 2010 at 9:57

GoogleCodeExporter commented 9 years ago

Original comment by aglad...@gmail.com on 26 Feb 2012 at 2:22