pkulchenko / wxlua

wxlua: Lua bindings for wxWidgets cross-platform GUI toolkit; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and wxWidgets 3.x
306 stars 59 forks source link

Segmentation faults on OSX 64-bit builds #14

Closed ghost closed 5 years ago

ghost commented 6 years ago

Hi,

I am trying to get wxlua running on 64-bit Mac OSX. I have oriented myself on the ZBS build scripts and on 64-bit Linux everything compiles and runs fine. On both platforms I have used exactly the same sources:

On OSX 64-bit everything also compiles well, but tests with wxlua fail on memory management. With Luajit the libwx does not load but fails in wxLuaEvent object destruction and with Lua 5.1 it fails on the "unittest.wx.lua" as soon as the garbagecollector comes into action, see output below.

Could you please let me know if there is a way to fix this? Please let me know if more details are needed.

Many thanks in advance!

Best regards, chyfx

Attached please find the debugging/test results: log.txt

ghost commented 6 years ago

Dear Paul,

thank you for looking into this.

Just a heads-up, I now also got a working wxlua DLL with 64-bit MinGW compiler for the Windows platform.

Please let me know how I can support this issue.

Many thanks!

Kind greetings, chyfx

pkulchenko commented 6 years ago

@chymanfx, I'm curious about what results you get with LuaJIT 2.1 (there have been many changes between 2.0.5 and 2.1) and wxWidgets 3.1.1, which should be the latest released version. I'll be switching to 64bit version on MacOS shortly, so am interested in your results. How did you compile wxwidgets on OSX? What build scripts are you using?

ghost commented 6 years ago

Thank you for your response. I have attached the bash script I use for build process, it is derived from your ZBS build script: build-osx64.txt

I will check how LuaJIT 2.1 behaves, but I don't expect a change here (I may have tried that already). As for wxWidgets 3.1.1, OSX 10.6.8 is not supported any more. But to me it looks like the problem happens on wxlua init before much wxWidgets code comes into play, please see the attached log on 1st post. Hope that brings some light...

Kind greetings!

ghost commented 6 years ago

I have build and tested with LuaJIT 2.1.0-beta3 and also with Lua 5.1.5 both show issues with the GC.

Please see the attached crash files: crash_luajit21.txt crash_lua515.txt

I assume that both are caused by the same problem, only that the GC becomes active at a later time on Lua 5.1.5 and thus triggers the issue somewhat later.

Kind greetings!

ghost commented 5 years ago

I found a solution to my issue: On linking the libwx library I statically linked in liblua.a (5.1.5), that works fine on Linux, but seems to be an issue for OSX. When linking libwx with dynamic liblua.dylib it also works on OSX. The fact that the NULL pointer exceptions occurring on calls to lua_gc happened in C++ std library gave me hint to library address space mismatches: lua_gc should only call into C libraries and not into C++ libraries.