Discussion:
how to make "bad callback" more deterministic
Cosmin Apreutesei
2014-07-18 00:37:12 UTC
Permalink
Hi,

Sorry in advance for the "dissatisfied customer" tone (this doesn't
happen as often as the tone implies).

Here's my situation:

My callback-ridden code sometimes panics with "bad callback", and it
makes it hard to trust that it won't break on a user's machine because
of a slightly different call order that I can't reproduce easily (and
unit-test for) due to the async nature of the issue. Also, for panics
that happen rarely, it's hard to really be sure that I even applied
jit.off() to the right function. It kinda makes me paranoid.

I would like to find a way to make these panics more deterministic,
eg. a compile option to disable the automatic jit guards would maybe
make them trigger more rapidly and/or often?

Mike, any tips?

What do people do when confronted with this?

Thanks.
Alex
2014-07-18 00:49:19 UTC
Permalink
The bad callback error happens because some JIT-compiled Lua code calls a C
function which in turn calls an FFI callback. Just blacklist those
functions and you should be good.

For C functions that call callbacks, I usually wrap it in a Lua function,
call jit.off on it, and use the wrapper in place of the FFI function. (The
wrapper is neccessary because jit.off doesn't work on FFI functions.)
--
Sincerely,
Alex Parrill
Loading...