Re: 2.1 crash using module with ffi

  • From: Mike Pall <mike-1401@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 22 Jan 2014 09:02:28 +0100

William Adams wrote:
> I get a crash trying to use a FFI function from a module.

The module is unloaded, since the namespace handle is garbage
collected.

> local Lib = ffi.load("psapi");
> return {
>  EnumProcesses = Lib.EnumProcesses, 
> }

You need to anchor 'Lib' somewhere. E.g. in the returned table.

http://luajit.org/ext_ffi_semantics.html#clib

--Mike

Other related posts: