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

wxWidgets Debug alert make luajit crash #28

Closed sonoro1234 closed 5 years ago

sonoro1234 commented 5 years ago

Is there something I can do to avoid it? I think this is wxWidget debug alert that does not arrive to wxLua so there is no message about the lua code triggering it, and so it is difficut to track.

wxDisableAsserts seems not wrapped by wxLua

defining wxDEBUG_LEVEL = 0 before wxWidgets compilation seems the only way to get rid of them

pkulchenko commented 5 years ago

@sonoro1234, any further details on this? How do you trigger the alert? Any details from the stack trace after the crash?

sonoro1234 commented 5 years ago

The alert was triggered by lua code: Inserting with CENTER_HORIZONTAL in a wxBoxSizer with horizontal style.

wxWidgets were compiled in debug mode but wxLua with Release mode (my fault).

Now compiled all in debug mode: Does not happen if I introduce this error in editor.wx.lua Only happens in my multithreaded (with lanes) application Lua2SC

warning: C:\supercolliderrepos\Lua2SC\wxLuaBundled\wxWidgets\src\common\sizer.cpp(2108): assert "!(flags & wxA
LIGN_CENTRE_HORIZONTAL)" failed in DoInsert(): Horizontal alignment flags are ignored in horizontal sizers

Thread 4 received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 5424.0x135c]
0x690080f1 in wxDefaultAssertHandler(wxString const&, int, wxString const&, wxString const&, wxString const&)
() from C:\supercolliderrepos\build_Lua2SCdebug\install\wx.dll
(gdb) thread apply all bt

and thread 4:

Thread 4 (Thread 6268.0x15f0):
#0  0x690080f1 in wxDefaultAssertHandler(wxString const&, int, wxString const&, wxString const&, wxString cons
t&) () from C:\supercolliderrepos\build_Lua2SCdebug\install\wx.dll
#1  0x6900886a in wxOnAssert(char const*, int, char const*, char const*, wchar_t const*) ()
   from C:\supercolliderrepos\build_Lua2SCdebug\install\wx.dll
#2  0x68e8cba6 in wxBoxSizer::DoInsert(unsigned int, wxSizerItem*) ()
   from C:\supercolliderrepos\build_Lua2SCdebug\install\wx.dll
#3  0x6924ba9c in wxSizer::Insert(unsigned int, wxSizerItem*) ()
   from C:\supercolliderrepos\build_Lua2SCdebug\install\wx.dll
#4  0x6924b750 in wxSizer::Add (this=0x4a24230, item=0x5088250)
    at C:/supercolliderrepos/build_Lua2SCdebug/wxWidgets_install/include/wx/sizer.h:1155
#5  0x6924b8fa in wxSizer::Add (this=0x4a24230, sizer=0x5086ec8, proportion=0, flag=496, border=0,
    userData=0x0) at C:/supercolliderrepos/build_Lua2SCdebug/wxWidgets_install/include/wx/sizer.h:1167
#6  0x68bc2732 in wxLua_wxSizer_Add1 (L=0x49efe8)
    at C:\supercolliderrepos\Lua2SC\wxLuaBundled\wxlua\wxLua\modules\wxbind\src\wxcore_sizer.cpp:1537
#7  0x68c24f12 in wxlua_callOverloadedFunction (L=0x49efe8, wxlMethod=0x69392440 <wxSizer_methods>)
    at C:\supercolliderrepos\Lua2SC\wxLuaBundled\wxlua\wxLua\modules\wxlua\wxlbind.cpp:520
#8  0x68c24cb0 in wxlua_callOverloadedFunction (L=0x49efe8)
    at C:\supercolliderrepos\Lua2SC\wxLuaBundled\wxlua\wxLua\modules\wxlua\wxlbind.cpp:434
#9  0x66f82d22 in lj_BC_FUNCC () from C:\supercolliderrepos\build_Lua2SCdebug\install\lua51.dll
#10 0x0049efe8 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

and after (gdb) continue all happens again and again without crashing in gdb

The same debuging with editor.wx.lua modified for triggering the assert only prints the warning but dont makes SIGTRAP (why??) but instead got SIGSEGV on closing and trace

Thread 1 (Thread 2776.0xefc):
#0  0x69209110 in ?? ()
#1  0x75c77451 in USER32!CallNextHookEx () from C:\Windows\syswow64\user32.dll
#2  0x75c680a9 in USER32!GetUserObjectInformationW () from C:\Windows\syswow64\user32.dll
#3  0x00030000 in ?? ()
#4  0x75c68ba1 in USER32!RegisterClassW () from C:\Windows\syswow64\user32.dll
#5  0x7776013a in ntdll!KiUserCallbackDispatcher () from C:\Windows\SysWOW64\ntdll.dll
#6  0x0028fc48 in ?? ()
#7  0x75c70769 in USER32!PeekMessageW () from C:\Windows\syswow64\user32.dll
#8  0x759f602c in TF_GetInputScope () from C:\Windows\syswow64\msctf.dll
#9  0x759f61da in TF_GetInputScope () from C:\Windows\syswow64\msctf.dll
#10 0x759f5b18 in TF_GetInputScope () from C:\Windows\syswow64\msctf.dll
#11 0x777893c5 in ntdll!RtlIsCurrentThreadAttachExempt () from C:\Windows\SysWOW64\ntdll.dll
#12 0x0028df58 in ?? ()
#13 0x777a8efe in ntdll!LdrShutdownProcess () from C:\Windows\SysWOW64\ntdll.dll
#14 0x004e6220 in ?? ()
#15 0x777a8e4a in ntdll!RtlExitUserProcess () from C:\Windows\SysWOW64\ntdll.dll
#16 0x771e7a3d in KERNEL32!ExitProcess () from C:\Windows\syswow64\kernel32.dll
#17 0x00000000 in ?? ()
sonoro1234 commented 5 years ago

I have managed to compile wxWidgets and wxLuaModule with wxDEBUG_LEVEL = 0 and the assertions dissappear avoiding the crash.

It would be much more convenient to wrap wxDisableAsserts function so that we can use asserts or not at will.

pkulchenko commented 5 years ago

I have managed to compile wxWidgets and wxLuaModule with wxDEBUG_LEVEL = 0 and the assertions dissappear avoiding the crash.

@sonoro1234, I use the same configuration for non-debug builds, so not sure what may be going on with the assertions and don't plan to work on this in the near future. Feel free to re-open if you have some additional information or have time to work on this.