lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Yang Fan wrote:
> I have a C++ program which embeds Lua interpreter and registers
> several classes, then replace the Lua interpreter dll with
> LuaJIT2's. The C++ program calls a Lua function which would call
> C++ functions registered by Luabind, and if the called C++
> functions are invalid the C++ program may crash, but the
> officila Lua won't, please see the attachment for example.

The example works fine for me on Linux/x64, but I can't test this
easily on Windows. And the sources of luabind and boost are
incomprehensible, so I'm at a loss what really happens.

You could attach a debugger to see where it's crashing. The
interesting path starts somwehere at:
  luabind::detail::class_rep::static_class_gettable()

It could be that luabind tries to throw exceptions across Lua
frames or tries to throw Lua errors across C++ frames protected
with try/catch (works on Windows/x64, crashes on Windows/x86).
Or maybe luabind and/or boost need to be compiled with other VC++
flags for exception interoperation.

You may experiment with setting LUABIND_NO_ERROR_CHECKING or
LUABIND_NO_EXCEPTIONS in luabind/config.hpp to work around this.

> Also I found wxLua's class member methods working with LuaJIT2
> have the same problem.

As far as I could glean from the sources, it throws Lua errors deep
inside some C++ mess. Might be a similar issue.

--Mike