lua-users home
lua-l archive

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




On Fri, Sep 16, 2011 at 8:11 AM, Gaspard Bucher <gaspard@teti.ch> wrote:


On Thu, Sep 15, 2011 at 10:15 PM, Gaspard Bucher <gaspard@teti.ch> wrote:
I have this strange case where up-values in a coroutine are garbage collected but the coroutine is not (and when it runs, the userdata has 0x0 pointers).

Here is my dependency graph (~~~ = weak value) :

scheduler ---> wrap ---> t ~~~~~> thread ---> coroutine --- (up-value) --> foobar ---> super (userdata)

From my understanding, when "foobar" or "thread" goes out of scope, the whole thing should be garbage collected. What is happening is that only the
userdata inside foobar is collected but foobar is still a table. This table does not have any special mode.

getmetatable(foobar)
=> nil

Any clues on this would be greatly appreciated..

Cheers,


                                                               Gaspard

This is still failing... When I add a debug objects (prints a string on gc):

-------------- ~D  (debug object garbage collected)
<lk.Debug: 0x0>  (I can do a print on the debug object)

As we can see above, the debug object has been garbage collected but I can still print it which means the object is accessible through the coroutine and should not be collected.

Graphical view: https://gist.github.com/1221403

Further analysis shows me that if I nil the 'thread' object before 'foobar', the problem is resolved because the coroutine is garbage collected.

Any idea, debugging tool, direction to help solve this issue would be greatly appreciated...

Cheers,

Gaspard