On 16 January 2013 22:43, Cosmin Apreutesei <cosmin.apreutesei@xxxxxxxxx> wrote: > Hi, > > I have a noobie C + ffi question: libpng and libjpeg use exit() after > fatal errors, but they let you set up an error callback - and they say > that control from the callback should not be returned to the caller. > In C I would call longjmp() to get out of the callback. In Lua I raise > an error from the callback. I had no problem with this so far but is > this actually safe/supported by luajit/ffi ? 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? henk