Re: Random crashes with ABC enabled

  • From: Richard Hundt <richardhundt@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 27 Mar 2014 21:01:33 +0100

On 3/27/14 7:55 PM, demetri wrote:
>
>
>     Could you confirm that by "unanchored FFI cdata" you mean native
>     arrays which are deallocated randomly by non-Lua part?
>
>
>
>
> -- Case 3 (unanchored return of ffi.new())
> local function baz ()
>   local x = ffi.new(whatever)
>   -- do some stuff to x
>   return x 
>   -- oops! nothing references the memory from ffi.new when local x
> goes out 
>   -- of scope!
> end
>
>

So are you saying that if - using your example - I do:

local x = baz()

that x can get collected out from under me? I don't think that's right.
I've always relied on cdata being collected when they're not in any GC
roots.

Other related posts: