Re: raising an error from a ffi callback

  • From: Mike Pall <mike-1301@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 18 Jan 2013 01:45:01 +0100

Henk Boom wrote:
> I'm encountering this issue as well. I know that in vanilla lua
> longjump is used to handle errors, which would seem to be compatible
> with how libpng wants you to handle errors (i.e. their default error
> handler does this), but I've heard that luajit does more complicated
> things to interoperate with c++ and such. Is this a safe thing to do?

As Florian said, you need to use jit.off(func) for the Lua
function that has the code that calls into the C function that may
eventually call back into Lua.

Whether that Lua code throws an error or not is orthogonal to the
callback problem. Throwing errors across C frames is fine. For C++,
the rules in http://luajit.org/extensions.html#exceptions apply.

--Mike

Other related posts: