Cosmin Apreutesei
2014-07-02 09:37:24 UTC
Hi,
I noticed that pinning objects in ffi.gc finalizers() doesn't work, at
least not when the program exits -- it's like the upvalues of the
finalizer are weak references. Is this a bug or a feature?
Example:
local heap = ffi.gc(CreateHeap(), FreeHeap)
local mem = ffi.gc(CreateMem(heap, size), function(mem)
FreeMem(heap, mem) -- heap pinned in mem's finalizer
end)
When the program exits, sometimes heap's finalizer is called before
mem's finalizer, even though mem's finalizer pins heap.
I noticed that pinning objects in ffi.gc finalizers() doesn't work, at
least not when the program exits -- it's like the upvalues of the
finalizer are weak references. Is this a bug or a feature?
Example:
local heap = ffi.gc(CreateHeap(), FreeHeap)
local mem = ffi.gc(CreateMem(heap, size), function(mem)
FreeMem(heap, mem) -- heap pinned in mem's finalizer
end)
When the program exits, sometimes heap's finalizer is called before
mem's finalizer, even though mem's finalizer pins heap.