Discussion:
wxCocoa crash on initialization
Деян Хаджиев
2014-06-03 13:29:51 UTC
Permalink
Hi,

I've been struggling with a problem with wxWidgets 3.1 on OSX-Cocoa for
several days, and couldn't find where's the origin of the problem (I'm
still searching though). The problem is that the application crashes even
before it's OnInit() function is called. I have an DECLARE_APP(MyApp) and
IMPLEMENT_APP_NO_MAIN(MyApp) macros in the compilation unit. This is a copy
of the stack frames:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x0000000101051aa0 in -[wxNSAppController applicationWillFinishLaunching:]
(self=0x10500b8c0, _cmd=0x7fff88988588, application=0x102543b80) at
../src/osx/cocoa/utils.mm:67
67 wxTheApp->OSXOnWillFinishLaunching();
(gdb) bt
#0 0x0000000101051aa0 in -[wxNSAppController
applicationWillFinishLaunching:] (self=0x10500b8c0, _cmd=0x7fff88988588,
application=0x102543b80) at ../src/osx/cocoa/utils.mm:67
#1 0x00007fff81564ad5 in _nsnote_callback ()
#2 0x00007fff88d36fd0 in __CFXNotificationPost ()
#3 0x00007fff88d23548 in _CFXNotificationPostNotification ()
#4 0x00007fff8155ba36 in -[NSNotificationCenter
postNotificationName:object:userInfo:] ()
#5 0x00007fff81979901 in -[NSApplication finishLaunching] ()
#6 0x00007fff81979554 in -[NSApplication run] ()
#7 0x00000001010523b4 in wxApp::CallOnInit (this=0x10253f700) at
../src/osx/cocoa/utils.mm:448
#8 0x00000001002ed5b2 in wxEntry () at ../src/common/init.cpp:479

It seems that wxTheApp is NULL, but I could not check it in the debugger
(no symbol "wxTheApp" in current context, although my build is with
--enable-debug). I could not recreate the problem with the minimal sample.
I don't know if this is relevant, but wxWidgets library is statically
linked to a shared library in my application. I thought that this may be of
some importance.
TIA for any help.

Best regards
Deyan Hadzhiev
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Stefan Csomor
2014-06-03 20:00:58 UTC
Permalink
Hi

I've been struggling with a problem with wxWidgets 3.1 on OSX-Cocoa for several days, and couldn't find where's the origin of the problem (I'm still searching though). The problem is that the application crashes even before it's OnInit() function is called. I have an DECLARE_APP(MyApp) and IMPLEMENT_APP_NO_MAIN(MyApp) macros in the compilation unit. This is a copy of the stack frames:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x0000000101051aa0 in -[wxNSAppController applicationWillFinishLaunching:] (self=0x10500b8c0, _cmd=0x7fff88988588, application=0x102543b80) at ../src/osx/cocoa/utils.mm:67<http://utils.mm:67>
67 wxTheApp->OSXOnWillFinishLaunching();
(gdb) bt
#0 0x0000000101051aa0 in -[wxNSAppController applicationWillFinishLaunching:] (self=0x10500b8c0, _cmd=0x7fff88988588, application=0x102543b80) at ../src/osx/cocoa/utils.mm:67<http://utils.mm:67>
#1 0x00007fff81564ad5 in _nsnote_callback ()
#2 0x00007fff88d36fd0 in __CFXNotificationPost ()
#3 0x00007fff88d23548 in _CFXNotificationPostNotification ()
#4 0x00007fff8155ba36 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#5 0x00007fff81979901 in -[NSApplication finishLaunching] ()
#6 0x00007fff81979554 in -[NSApplication run] ()
#7 0x00000001010523b4 in wxApp::CallOnInit (this=0x10253f700) at ../src/osx/cocoa/utils.mm:448<http://utils.mm:448>
#8 0x00000001002ed5b2 in wxEntry () at ../src/common/init.cpp:479

It seems that wxTheApp is NULL, but I could not check it in the debugger (no symbol "wxTheApp" in current context, although my build is with --enable-debug). I could not recreate the problem with the minimal sample. I don't know if this is relevant, but wxWidgets library is statically linked to a shared library in my application. I thought that this may be of some importance.

if you have IMPLEMENT_APP_NO_MAIN then somewhere in the init process wxCreateApp must be called and then wxApp::SetInstance must be called from the init sequence, so that wxTheApp which is short for wxApp::GetInstance can return something reasonable. The strange thing is that in init.cpp line 479 we have wxTheApp->CallOnInit() and utils.mm 67 has wxTheApp->OSXOnWillFinishLaunching()so why didn't it crash at the first ptr dereference ? could it be we have two different instance in two libraries ?

Just my 0.02$

Best,

Stefan
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Деян Хаджиев
2014-06-03 21:28:39 UTC
Permalink
Hi,
Post by Stefan Csomor
The strange thing is that in init.cpp line 479 we have wxTheApp->
CallOnInit() and utils.mm 67 has
Post by Stefan Csomor
wxTheApp->OSXOnWillFinishLaunching()so why didn't it crash at the first
ptr dereference ? could it be
Post by Stefan Csomor
we have two different instance in two libraries ?
Maybe that is the problem after all, because I also noticed that when I set
breakpoint from gdb in OSXOnWillFinishLaunching() for example, it actually
set two breakpoints instead of just one. I should investigate deeper if
somewhere the wxWidgets library is linked twice unnoticed. Thanks for the
help, I will try the other suggestion as well.

Regards
Deyan Hadzhiev
Post by Stefan Csomor
Hi
I've been struggling with a problem with wxWidgets 3.1 on OSX-Cocoa
for several days, and couldn't find where's the origin of the problem (I'm
still searching though). The problem is that the application crashes even
before it's OnInit() function is called. I have an DECLARE_APP(MyApp) and
IMPLEMENT_APP_NO_MAIN(MyApp) macros in the compilation unit. This is a copy
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x0000000101051aa0 in -[wxNSAppController applicationWillFinishLaunching:]
(self=0x10500b8c0, _cmd=0x7fff88988588, application=0x102543b80) at
../src/osx/cocoa/utils.mm:67
67 wxTheApp->OSXOnWillFinishLaunching();
(gdb) bt
#0 0x0000000101051aa0 in -[wxNSAppController
applicationWillFinishLaunching:] (self=0x10500b8c0, _cmd=0x7fff88988588,
application=0x102543b80) at ../src/osx/cocoa/utils.mm:67
#1 0x00007fff81564ad5 in _nsnote_callback ()
#2 0x00007fff88d36fd0 in __CFXNotificationPost ()
#3 0x00007fff88d23548 in _CFXNotificationPostNotification ()
#4 0x00007fff8155ba36 in -[NSNotificationCenter
postNotificationName:object:userInfo:] ()
#5 0x00007fff81979901 in -[NSApplication finishLaunching] ()
#6 0x00007fff81979554 in -[NSApplication run] ()
#7 0x00000001010523b4 in wxApp::CallOnInit (this=0x10253f700) at
../src/osx/cocoa/utils.mm:448
#8 0x00000001002ed5b2 in wxEntry () at ../src/common/init.cpp:479
It seems that wxTheApp is NULL, but I could not check it in the debugger
(no symbol "wxTheApp" in current context, although my build is with
--enable-debug). I could not recreate the problem with the minimal sample.
I don't know if this is relevant, but wxWidgets library is statically
linked to a shared library in my application. I thought that this may be of
some importance.
if you have IMPLEMENT_APP_NO_MAIN then somewhere in the init process
wxCreateApp must be called and then wxApp::SetInstance must be called from
the init sequence, so that wxTheApp which is short for wxApp::GetInstance
can return something reasonable. The strange thing is that in init.cpp line
479 we have wxTheApp->CallOnInit() and utils.mm 67 has wxTheApp->
OSXOnWillFinishLaunching()so why didn't it crash at the first ptr
dereference ? could it be we have two different instance in two libraries ?
Just my 0.02$
Best,
Stefan
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...