q66 / cffi-lua

A portable C FFI for Lua 5.1+
MIT License
182 stars 24 forks source link

Interaction between cffi and lgi causes crashes #48

Open xinhaoyuan opened 5 months ago

xinhaoyuan commented 5 months ago

Hi, please see the below code for demo.

-- Uncommenting the line below will introduce a crash in callback:free().
require("cffi")
local lgi = require("lgi")
local callback = require("cffi").cast("void (*)()", function() end)
print("Before free")
callback:free()
print("After free")

I'm using cffi from luarocks, lua 5.1, and lgi from Debian repo (unstable).