[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Patch] Finalization of function objects
- From: "Thomas Harning Jr." <harningt@...>
- Date: Fri, 31 Jul 2009 15:23:21 -0400
On Fri, Jul 31, 2009 at 3:07 PM, Thomas Harning Jr.<harningt@gmail.com> wrote:
> Any further work in the finalization patch?
>
> I tried rebuilding to see if perhaps it was my environment at the
> time, but I get the same error:
>
> x86_64
> http://pastebin.com/m69d835c0
> x86
> http://pastebin.com/m43f079ac
>
> I'll try to dig into this more tonight...
I've narrowed this down to the GC'ed coroutine. Ah hah!
do
local g
function collect() g = true end
local function foo()
finally(collect)
coroutine.yield()
end
local co = coroutine.create(foo)
coroutine.resume(co)
-- force GC
co = nil
collectgarbage("collect")
assert(g, "Not finalized")
print"OK"
end
Works
do
local g
local function foo()
finally(function() g = true end)
coroutine.yield()
end
local co = coroutine.create(foo)
coroutine.resume(co)
-- force GC
co = nil
collectgarbage("collect")
assert(g, "Not finalized")
print"OK"
end
Does not safely work!
My guess is that the locally defined function somehow got cleaned up
during the coroutine finalization.... then the op got called and it
passes due to the fact that the memory hadn't yet been written over.
I don't know how valgrind misses it on your system (from way back)...
but I can reproducibly cause valgrind errors and 'fix' them. Now to
see how in the world to fix this in the patch.
--
Thomas Harning Jr.