You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to adapt an existing LuaJIT+ffi project such that it could run with Lua as well using the cffi package. Doing so I am stuck with the following use case. When assigning a Lua callback to a C struct I get a segfault. Yet it works with LuaJIT. Below is a minimal example:
okay, that's fixed now, but generally don't do this; you have no way to :free() the callback afterwards, so you leak resources, and with luajit it's especially bad considering the callback limits
you should always cast the lua function first, then save the result, pass it where you want it, and explicitly :free() the callback once you're done with it
I missed this point indeed. Usually my application uses only a few callbacks. Yet it could be problematic indeed. I will change this and make sure to :free().
Hello,
thank you for this great work :)
I am trying to adapt an existing
LuaJIT+ffi
project such that it could run withLua
as well using thecffi
package. Doing so I am stuck with the following use case. When assigning aLua
callback to aC
struct I get a segfault. Yet it works withLuaJIT
. Below is a minimal example:The last line gives a segfault on Debian using
Lua 5.4
+cffi
. What could be the reason?The text was updated successfully, but these errors were encountered: