[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: kill coroutine
- From: Mike Pall <mikelu-0508@...>
- Date: Sun, 21 Aug 2005 14:12:13 +0200
Rici Lake wrote:
> The currently running thread (and therefore its stack) are always part
> of the gc root. So is the "main thread" (and its stack).
That's not how it works internally in Lua 5.1 anymore.
Have a look at markroot() in lgc.c. Nowhere does it mark L,
the running thread (that called luaC_step).
However a running thread should always have a reference in
the thread that resumed it and so on until the main thread
(which _is_ marked as part of the gc root).
> If there is no reference left to a coroutine and the coroutine yields,
> then it will get garbage collected at some point.
Remove the '... and the coroutine yields ...'.
It's a common pitfall when using coroutines from C, to forget
holding a reference to the resumed coroutine. Then it's suddenly
deallocated and you get random crashes (or a nice error from