I have succeeded at https://github.com/q66/cffi-lua , subtask "callbacks without random crashes", and the answer is "assign the callback to a local variable, otherwise the gc collects it". yes it's logical that the gc doesn't scan C address space looking for roots, I suppose, but it took an awful long time before I realised this was the problem


GitHub - q66/cffi-lua: A portable C FFI for Lua 5.1+

A portable C FFI for Lua 5.1+. Contribute to q66/cffi-lua development by...