wxAUI sample application crashes on Mac

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
jvenema
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Jun 16, 2017 6:27 am

wxAUI sample application crashes on Mac

Post by jvenema »

I creating an application using the wxAui stuff and have some strange behaviour with it on the Mac platform, the other two platforms I develop against (windows 10 & Ubuntu 16.04) seems to work ok.
My application crashes when dragging a floating window around, or while trying to resize a floating window.
I tried trim down the problem and now I'm in the situation that the sample application as it shown on the Wiki page and on other places does not even start, before seeing anything it crashes. It works fine on the other platforms.
The code I use that crashes immediately is:

Code: Select all

#include <wx/wx.h>
#include <wx/aui/aui.h>
 
class MyFrame : public wxFrame {
 public:
   MyFrame(wxWindow* parent) : wxFrame(parent, -1, _("wxAUI Test"),
                      wxDefaultPosition, wxSize(800,600),
                      wxDEFAULT_FRAME_STYLE)                              
   {
     // notify wxAUI which frame to use
     m_mgr.SetManagedWindow(this);
 
     // create several text controls
     wxTextCtrl* text1 = new wxTextCtrl(this, -1, _("Pane 1 - sample text"),
                      wxDefaultPosition, wxSize(200,150),
                      wxNO_BORDER | wxTE_MULTILINE);
                                        
     wxTextCtrl* text2 = new wxTextCtrl(this, -1, _("Pane 2 - sample text"),
                      wxDefaultPosition, wxSize(200,150),
                      wxNO_BORDER | wxTE_MULTILINE);
                                        
     wxTextCtrl* text3 = new wxTextCtrl(this, -1, _("Main content window"),
                      wxDefaultPosition, wxSize(200,150),
                      wxNO_BORDER | wxTE_MULTILINE);
         
     // add the panes to the manager
     m_mgr.AddPane(text1, wxLEFT, wxT("Pane Number One"));
     m_mgr.AddPane(text2, wxBOTTOM, wxT("Pane Number Two"));
     m_mgr.AddPane(text3, wxCENTER);
                               
     // tell the manager to "commit" all the changes just made
     m_mgr.Update();
   }
 
   ~MyFrame()
   {
     // deinitialize the frame manager
     m_mgr.UnInit();
   }
 
 private:
     wxAuiManager m_mgr;
 };
 
  // our normal wxApp-derived class, as usual
 class MyApp : public wxApp {
 public:
 
   bool OnInit()
   {
     wxFrame* frame = new MyFrame(NULL);
     SetTopWindow(frame);
     frame->Show();
     return true;                    
   }
 };
 
 DECLARE_APP(MyApp);
 IMPLEMENT_APP(MyApp);
[/color]

When trying to follow the stuff in the debugger with a version of wxWidgets compiled with debug information I come into the function/method:
void wxGUIEventLoop::OSXDoRun()
and in this function it calls:
[NSApp run];
I cannot enter this with debugger, the moment I try to enter it the application crashes.
Attached screenshots of the call stack and the threads. When the my more complex application crashes it is also always with the same message in strlen in the threads window. The call stack is then a bit different, but my feeling is that the underlying cause is the same.
I also build the aui demo from the samples directory, that is a far more complicated application as the simple example, but that one works fine on Mac!
I normally build against an own build wxWidgets from the 3.1.0 sources.
It is build after configuring it with the following command:
../configure --disable-shared --with-macosx-version-min=10.9 --enable-mediactrl=no --enable-monolithic --with-expat=builtin
Thus a static monolithic library and no media stuff, since that breaks the build.
Also other builds non monolithic and with debug info fails.
I tried both clang and the GNU gcc but no difference. I use Codelite as IDE.
I also cloned the latest code from github and build that version of wxWidgets all with the same result.

So if anyone has any suggestion on what is going on here and how to fix it, that would be very appreciated.
Attachments
Screen Shot 2017-06-16 at 08.52.10.png
Screen Shot 2017-06-16 at 08.52.10.png (58.8 KiB) Viewed 2119 times
Screen Shot 2017-06-16 at 08.49.25.png
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxAUI sample application crashes on Mac

Post by doublemax »

Do you see the same crash in the "aui" sample?
Use the source, Luke!
jvenema
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Jun 16, 2017 6:27 am

Re: wxAUI sample application crashes on Mac

Post by jvenema »

No the aui sample does not crash, but I'm a bit closer to the cause, but not to a solution.
The crash is on my MacBook pro, but not on my iMac! So I put the working exe build on my iMac to my MacBook and it crashed there. The exe build on the MacBook works fine on the iMac.
The next thing I did was use otool on a sample crash application, to see which dynlibs are used and which versions. I compared the set on the two platforms and it uses the same stuff and the same versions.
Then I did an md5 on all files mentioned by otool, to see if not one of them was corrupted somehow. The hashes were all the same between the two machines.
When running the application outside the IDE environment you get the option to send a crash report and I did look into the report, see also attachment.
Here also the strlen is reported, but the call stack is more readable then the '?' in the IDE. I noticed that assuming that the names are meaning full it tries to do something with the touch bar. I Repeated a few crashes and recorded the screen and the touch bar in slow motion mode. And at the crash you see something happening with the touch bar.
Somehow the crash is related with the touch bar in my opinion and therefor the crash is there on my mac book and not on my imac. Also all other platforms work fine also, If I do a windows build or linux and run those via a VM on my MacBook all is fine.
Seems like apple has to add somewhere an if stament in their code, so they do no longer call strlen on a null pointer. Until that moment I'm rather limited in my application development and testing. I have to be careful not to do to much dragging and dropping of the windows, since that will crash my application. But the simple example application doesn't even start up! Thus perhaps I make a small adjustment and it no longer works and then I'm stuck on my MacBook. I can not always work on my iMac, so I'm not to happy about the issue at the moment. I just invested on my new MacBook Pro to be able to develop decently on location and now this pops up.
Attachments
crashReport.txt
(55.49 KiB) Downloaded 87 times
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxAUI sample application crashes on Mac

Post by doublemax »

I don't work under OSX, so i can't help much. But i would research in the direction of finding out why the "aui" sample doesn't crash. It's a very wild guess, but first i'd try adding a menubar with all the default entrys and a statusbar to the frame.

What happens if you remove all AUI related stuff, does it still crash or not?

If you can reproduce the crash by making small changes to any of the standard samples, please open a bug report at: http://trac.wxwidgets.org/ (Server is really slow at the moment. If it doesn't work, please try again at a later time.)
Use the source, Luke!
jvenema
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Jun 16, 2017 6:27 am

Re: wxAUI sample application crashes on Mac

Post by jvenema »

I filed a Bug at Apple, it seems the error is on their side. As far as the crash report tell they just pass a NULL pointer into strlen, which is not a nice thing to do.
Further no issue on hardware without touchbar. Seems a rather clear case on who to blame ;-).
The strange thing is indeed that the small example crashes directly. My bit more complicated work in progress thing, with a bit fiddling on moving and resizing floating windows. And with the over the top demo aui application I do not see any problem at all. So something is masking the problem. And If you know what you have potentially a bad and non trustworthy workaround.
I spend half last night in changing code see whats is happening go forth and back between the different examples etc. The only thing I noticed is, that the simpler the example, the easier it crashes. I first noticed issues with my application, so I stripped it down to see, what I did wrong, then things became only worse.
djmig
Earned a small fee
Earned a small fee
Posts: 23
Joined: Wed Feb 10, 2016 11:18 pm

Re: wxAUI sample application crashes on Mac

Post by djmig »

I've never seen this kind of problem. I'm pretty sure the cause of your mishaps stems from your wxWidgets build. I recommend you to read:
https://wiki.wxwidgets.org/Compiling_wx ... (Terminal) and
http://www.appletonaudio.com/blog/2013/ ... s-and-c11/

My setup:

Code: Select all

../configure --disable-shared --enable-unicode --disable-sys-libs
Here is my result from compiling aui sample from wxWidgets' wiki page:
aui.png
aui.png (45.22 KiB) Viewed 2051 times
-----
MacBook Pro (2014), El Capitan, wxWidgets 3.1.0
jvenema
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Jun 16, 2017 6:27 am

Re: wxAUI sample application crashes on Mac

Post by jvenema »

Do you have a touchbar? The issue is only there on an apple device with touchbar. Apple has acknowledge, it is an issue, The my closed my issue, because it was a replication of an other issue, which is still open.
Passing a null pointer in strlen is always wrong and a bug.
Post Reply