wxWidgets 3.1.5 on Mac OS Big Sur and homebrew g++ 11,
this simple 2d plot sample from wxIshiko/wxCharts
builds fine, but it crashes on the following internal
Process 30764 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
frame #0: 0x0000000101ce2230 libwx_baseu-3.1.5.0.0.dylib`wxListBase::Append(this=0x0000600003e0f390, object=0x0000600003318000) at list.cpp:227:24
224
225 // we use wxDefaultListKey even though it is the default parameter value
226 // because gcc under Mac OS X seems to miscompile this call otherwise
-> 227 wxNodeBase *node = CreateNode(m_nodeLast, NULL, object,
228 wxDefaultListKey);
229
230 return AppendCommon(node);
It compiles and runs otherwise fine on Windows 10 and MSYS2-gcc.
It seems like the comment already points out for issues on Mac OS + gcc
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Please provide a full stack trace, just the information above is insufficient.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
This is the full stack:
(lldb)
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
* frame #0: 0x0000000101ce2230 libwx_baseu-3.1.5.0.0.dylib`wxListBase::Append(this=0x0000600003e0f390, object=0x0000600003318000) at list.cpp:227:24
frame #1: 0x00000001027ff5dc libwx_osx_cocoau_core-3.1.5.0.0.dylib`wxMenuItemList::Append(this=0x0000600003e0f390, object=0x0000600003318000) at menu.h:37:1
frame #2: 0x00000001027ff578 libwx_osx_cocoau_core-3.1.5.0.0.dylib`wxMenuBase::DoAppend(this=0x0000600003e0f300, item=0x0000600003318000) at menucmn.cpp:374:13
frame #3: 0x0000000102602964 libwx_osx_cocoau_core-3.1.5.0.0.dylib`wxMenu::DoAppend(this=0x0000600003e0f300, item=0x0000600003318000) at menu_osx.cpp:169:21
frame #4: 0x0000000102601bc0 libwx_osx_cocoau_core-3.1.5.0.0.dylib`wxMenuBase::Append(this=0x0000600003e0f300, itemid=-3, text=0x0000600003e0f368, help=0x000000016fdfee48, kind=wxITEM_NORMAL) at menu.h:67:16
frame #5: 0x0000000102601b14 libwx_osx_cocoau_core-3.1.5.0.0.dylib`wxMenu::Init(this=0x0000600003e0f300) at menu_osx.cpp:73:9
frame #6: 0x000000010000952c wxgui-mac`wxMenu::wxMenu(this=0x0000600003e0f300, style=0) at menu.h:33:54
frame #7: 0x0000000100062ebc wxgui-mac`WxMath2DFrame::WxMath2DFrame(this=0x00000001038aac00, title=0x000000016fdff4f8) at wx2dplot.cpp:18:29
frame #8: 0x0000000100067b40 wxgui-mac`wxgui_macApp::OnInit(this=0x0000000101808590) at wxgui_macApp.cpp:29:76
frame #9: 0x00000001025bfcac libwx_osx_cocoau_core-3.1.5.0.0.dylib`wxApp::CallOnInit(this=0x0000000101808590) at utils.mm:397:22
frame #10: 0x0000000101cd5e40 libwx_baseu-3.1.5.0.0.dylib`wxEntry(argc=0x0000000101e28be0, argv=0x00006000000043b0) at init.cpp:488:25
frame #11: 0x0000000101cd6060 libwx_baseu-3.1.5.0.0.dylib`wxEntry(argc=0x000000016fdff6bc, argv=0x000000016fdff820) at init.cpp:516:12
frame #12: 0x0000000100067a40 wxgui-mac`main(argc=1, argv=0x000000016fdff820) at wxgui_macApp.cpp:22:1
frame #13: 0x000000010021d0f4 dyld`start + 520
(lldb)
This is the frame class:
class WxMath2DFrame : public wxFrame
{
public:
WxMath2DFrame(const wxString& title);
protected:
wxMenuBar* m_menubar;
wxMenu* m_typeMenu;
wxMenu* m_axisMenu;
wxMenu* m_gridMenu;
private:
wxMath2DPlotCtrl* math2dPlotCtrl;
void Binds();
};
and the code breaks at:
WxMath2DFrame::WxMath2DFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title)
{
m_menubar = new wxMenuBar( 0 );
m_typeMenu = new wxMenu(); // code breaks at this line
wxMenuItem* m_line = new wxMenuItem( m_typeMenu, ID_LineChart, wxString( wxT("Line") ), wxEmptyString, wxITEM_RADIO );
m_typeMenu->Append( m_line );
[...etc...]
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
FYI it's an arm64 build
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
This looks very much like a mis-compilation problem, there is no way this code crashes if everything is built correctly, it's used by all (well, 99.99% of) wx applications.
Please check that you use the same compiler and compiler options for building the library and your example application. You can also confirm that it's not a wx bug by building the menu sample (or even the minimal one) from wx itself and checking that it works.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks for the hint. The error I posted comes when linking against a local wx3.1.5 build (using Apple's gcc which seems to be wrapping clang, while my program is built with homebrew-gcc). I installed homebrew-wxwidgets, which is 3.1.7, now linking against it so I'm only using homebrew compiler & libs. While the description is different, I get the same error:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
frame #0: 0x0000000100f151b4 libwx_baseu-3.1.dylib`wxListBase::Append(void*) + 124
libwx_baseu-3.1.dylib`wxListBase::Append:
-> 0x100f151b4 <+124>: ldr x8, [x8, #0x10]
0x100f151b8 <+128>: adrp x4, 294
0x100f151bc <+132>: add x4, x4, #0xd8 ; wxDefaultListKey
0x100f151c0 <+136>: mov x2, #0x0
Target 0: (wxgui-mac) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
* frame #0: 0x0000000100f151b4 libwx_baseu-3.1.dylib`wxListBase::Append(void*) + 124
frame #1: 0x000000010144d4c8 libwx_osx_cocoau_core-3.1.dylib`wxMenuBase::DoAppend(wxMenuItem*) + 36
frame #2: 0x000000010131059c libwx_osx_cocoau_core-3.1.dylib`wxMenu::DoAppend(wxMenuItem*) + 24
frame #3: 0x000000010130fc08 libwx_osx_cocoau_core-3.1.dylib`wxMenu::Init() + 212
frame #4: 0x0000000100009504 wxgui-mac`wxMenu::wxMenu(this=0x0000600003e16200, style=0) at menu.h:33:54
frame #5: 0x0000000100062e94 wxgui-mac`WxMath2DFrame::WxMath2DFrame(this=0x000000010301f200, title=0x000000016fdff628) at wx2dplot.cpp:18:29
frame #6: 0x0000000100067b2c wxgui-mac`wxgui_macApp::OnInit(this=0x0000000103807e50) at wxgui_macApp.cpp:27:82
frame #7: 0x00000001012e89c4 libwx_osx_cocoau_core-3.1.dylib`wxApp::CallOnInit() + 176
frame #8: 0x0000000100f10e44 libwx_baseu-3.1.dylib`wxEntry(int&, wchar_t**) + 80
frame #9: 0x0000000100067a2c wxgui-mac`main(argc=1, argv=0x000000016fdff858) at wxgui_macApp.cpp:22:1
frame #10: 0x000000010021d0f4 dyld`start + 520
(lldb)
Finally I've tried a local build of wxwidgets using g++-11 from homebrew, but it crashes because of this exact same error: apparently gcc doesn't support "blocks" which are in some of the Apple SDK headers
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Hmm, that's indeed problematic. User code doesn't need to include the SDK headers and so can be compiled with gcc, but wx code definitely doesn need to include them and if it can only be compiled with clang. And apparently gcc and clang are not ABI-compatible under macOS, which is not really that surprising, even if it is disappointing.
I don't think we can do anything about it, unfortunately. Blocks support is not going to be easy to add to gcc, as otherwise it would probably have been already done, but perhaps there is some way to configure gcc under macOS to use clang-compatible ABI? But this is pretty much outside of wx scope anyhow...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
You're right, the menu sample builds and runs just as expected with the system's clang-based g++, but it fails on this same error if I build it with homebrew-g++. I'll need to dig more into this issue as I have lots of Fortran code to bind, so clang is unfortunately not an option; but otherwise, I think you can close this ticket!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
BTW for future reference it really seems like macOS's core graphics libraries included in wx's internals are not compatible with GNU compilers, so building wxWidgets with gnu gcc won't be easy, here's an example:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGContext.h:21,
from /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBitmapContext.h:9,
from /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h:11,
from ../include/wx/osx/core/private.h:19,
from ../include/wx/osx/private.h:4,
from ../src/common/filefn.cpp:52:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPath.h:391:15: error: expected unqualified-id before '^' token
391 | typedef void (^CGPathApplyBlock)(const CGPathElement * element);
| ^
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks, I'll document that only clang can be used for building wxOSX. This is, again, quite sad, but unfortunately I don't think there is anything we can do about it.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Closed #22519 as completed via 08cd516.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()