[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: closure runs with garbage collected upvalue ?
- From: Gaspard Bucher <gaspard@...>
- Date: Thu, 15 Sep 2011 22:15:55 +0200
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.
Any clues on this would be greatly appreciated..
function mdns.Registration(service_type, name, port, func)
func = func or dummy
local self = constr(service_type, name, port)
self.d = lk.Debug("registration", self)
self.thread = lk.Thread(function()
while true do
sched:waitRead(self:fd()) -- there is a yield here
--- self.super is dead
func(self:getService()) ----> Segmentation fault