[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [LuaJIT FFI] [Windows] "bad callback" error in MsgWaitForMultipleObjects() proof-of-concept
- From: Mike Pall <mikelu-1112@...>
- Date: Fri, 23 Dec 2011 21:43:31 +0100
Duncan Cross wrote:
> What's happening is that the application is giving a "bad callback"
> error shortly after the application starts, especially when moving the
> mouse over the window.
> If I turn off JIT with jit.off(), it seems to stop happening.
The problem is that a FFI callback cannot safely be called from a
C function which is itself called via the FFI from JIT-compiled
code. In your case this is the call to MsgWaitForMultipleObjects.
I've put in a lot of heuristics to detect this, and it usually
succeeds in disabling compilation for such a function. However in
your case the loop is compiled before the callback is ever called,
so the detection fails.
The straighforward solution is to put the message loop into an
extra Lua function and use jit.off(func).