Qt5: Application crash on exit - c++

I have a c++ program written in Qt5 5.14.1.
It also use privoxy source code inside.
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff6b8e17fa __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff6b99ebc1 pthread_kill + 432
2 libsystem_c.dylib 0x00007fff6b868ab6 __abort + 139
3 libsystem_c.dylib 0x00007fff6b868a2b abort + 135
4 org.qt-project.QtCore 0x000000010b807de9 qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) + 9
5 org.qt-project.QtCore 0x000000010b809534 QMessageLogger::fatal(char const*, ...) const + 202
6 org.qt-project.QtCore 0x000000010b81060d QThread::~QThread() + 189
7 com.yourcompany.xxxxxxxx 0x00000001099cc935 PrivoxyThread::~PrivoxyThread() + 21 (privoxythread.cpp:17)
8 com.yourcompany.xxxxxxxx 0x00000001099cc955 PrivoxyThread::~PrivoxyThread() + 21 (privoxythread.cpp:17)
9 com.yourcompany.xxxxxxxx 0x00000001099cc979 PrivoxyThread::~PrivoxyThread() + 25 (privoxythread.cpp:15)
10 org.qt-project.QtCore 0x000000010ba0f394 QObjectPrivate::deleteChildren() + 228
11 org.qt-project.QtCore 0x000000010ba0f128 QObject::~QObject() + 2088
12 com.yourcompany.xxxxxxxx 0x00000001099e4598 Connection::~Connection() + 88 (connection.cpp:38)
13 com.yourcompany.xxxxxxxx 0x00000001099e4695 Connection::~Connection() + 21 (connection.cpp:38)
14 com.yourcompany.xxxxxxxx 0x00000001099e4819 Connection::~Connection() + 25 (connection.cpp:36)
15 org.qt-project.QtCore 0x000000010ba0f394 QObjectPrivate::deleteChildren() + 228
16 org.qt-project.QtCore 0x000000010ba0f128 QObject::~QObject() + 2088
17 com.yourcompany.xxxxxxxx 0x0000000109b9bd75 ConnectionItem::~ConnectionItem() + 21 (connectionitem.h:26)
18 com.yourcompany.xxxxxxxx 0x0000000109b9a0c5 ConnectionItem::~ConnectionItem() + 21 (connectionitem.h:26)
19 com.yourcompany.xxxxxxxx 0x0000000109b9a0e9 ConnectionItem::~ConnectionItem() + 25 (connectionitem.h:26)
20 org.qt-project.QtCore 0x000000010ba0f394 QObjectPrivate::deleteChildren() + 228
21 org.qt-project.QtCore 0x000000010ba0f128 QObject::~QObject() + 2088
22 com.yourcompany.xxxxxxxx 0x00000001099efe1d ConnectionTableModel::~ConnectionTableModel() + 61 (connectiontablemodel.cpp:8)
23 com.yourcompany.xxxxxxxx 0x00000001099efe65 ConnectionTableModel::~ConnectionTableModel() + 21 (connectiontablemodel.cpp:8)
24 com.yourcompany.xxxxxxxx 0x00000001099efe89 ConnectionTableModel::~ConnectionTableModel() + 25 (connectiontablemodel.cpp:8)
25 org.qt-project.QtCore 0x000000010ba0f394 QObjectPrivate::deleteChildren() + 228
26 org.qt-project.QtWidgets 0x000000010a9f7dae QWidget::~QWidget() + 1006
27 com.yourcompany.xxxxxxxx 0x0000000109a0c789 MainWindow::~MainWindow() + 409 (mainwindow.cpp:166)
28 com.yourcompany.xxxxxxxx 0x0000000109a0c825 MainWindow::~MainWindow() + 21 (mainwindow.cpp:166)
29 com.yourcompany.xxxxxxxx 0x00000001099fefcb main + 1339 (main.cpp:98)
30 libdyld.dylib 0x00007fff6b79a7fd start + 1
Each time I click quit, or Command + Q. It will quit and crash.
Is there a way to determine what cause the issue?
Apple Will pop a window when application crash, this is very annoying.

Related

Swift: crash at non-existing line

Hey StackOverflow detectives.
I've been pulling my hair out for a few months trying to figure out the crashes which happen at a line never exists.
In the crash log below, CustomClass.swift does exist but the line 25 doesn't.
What would be the true reason for this crash?
Hint: we run heavy processing and allocate a lot of memory (about 700MB) in the background that was written in c++, which is in OUR_CUSTOM_FRAMEWORK below.
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001934c6df0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001933e6930 pthread_kill + 228 (pthread.c:1458)
2 libsystem_c.dylib 0x0000000193374ba4 abort + 104 (abort.c:110)
3 libsystem_malloc.dylib 0x00000001933d7fdc malloc_vreport + 564 (malloc_printf.c:183)
4 libsystem_malloc.dylib 0x00000001933d81a4 malloc_report + 64 (malloc_printf.c:192)
5 libsystem_malloc.dylib 0x00000001933cbd1c free + 436 (malloc.c:1733)
6 [OUR_CUSTOM_FRAMEWORK] 0x000000010324ccf8 0x1031a4000 + 691448
7 libsystem_c.dylib 0x0000000193355164 __cxa_finalize_ranges + 416 (atexit.c:284)
8 libsystem_c.dylib 0x00000001933554a0 exit + 28 (exit.c:81)
9 UIKitCore 0x000000019782eb88 -[UIApplication _terminateWithStatus:] + 508 (UIApplication.m:6735)
10 UIKitCore 0x0000000196f97718 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 128 (_UISceneLifecycleMultiplexer.m:765)
11 UIKitCore 0x0000000196f9737c -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 220 (_UISceneLifecycleMultiplexer.m:418)
12 UIKitCore 0x0000000197824ac4 -[UIApplication workspaceShouldExit:withTransitionContext:] + 216 (UIApplication.m:3725)
13 FrontBoardServices 0x000000019893bcf8 -[FBSUIApplicationWorkspaceShim workspaceShouldExit:withTransitionContext:] + 88 (FBSUIApplicationWorkspace.m:144)
14 FrontBoardServices 0x0000000198968d68 __83-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:withAcknowledgement:]_block_invoke_2 + 80 (FBSWorkspaceScenesClient.m:281)
15 FrontBoardServices 0x000000019894debc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 240 (FBSWorkspace.m:357)
16 FrontBoardServices 0x0000000198968cf4 __83-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:withAcknowledgement:]_block_invoke + 140 (FBSWorkspaceScenesClient.m:278)
17 libdispatch.dylib 0x000000019338033c _dispatch_client_callout + 20 (object.m:495)
18 libdispatch.dylib 0x00000001933830d4 _dispatch_block_invoke_direct + 264 (queue.c:466)
19 FrontBoardServices 0x000000019898f6c4 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48 (FBSSerialQueue.m:173)
20 FrontBoardServices 0x000000019898f370 -[FBSSerialQueue _queue_performNextIfPossible] + 432 (FBSSerialQueue.m:216)
21 FrontBoardServices 0x000000019898f8dc -[FBSSerialQueue _performNextFromRunLoopSource] + 32 (FBSSerialQueue.m:247)
22 CoreFoundation 0x000000019365baf4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1922)
23 CoreFoundation 0x000000019365ba48 __CFRunLoopDoSource0 + 84 (CFRunLoop.c:1956)
24 CoreFoundation 0x000000019365b198 __CFRunLoopDoSources0 + 196 (CFRunLoop.c:1992)
25 CoreFoundation 0x0000000193655f38 __CFRunLoopRun + 796 (CFRunLoop.c:2882)
26 CoreFoundation 0x00000001936558f4 CFRunLoopRunSpecific + 480 (CFRunLoop.c:3192)
27 GraphicsServices 0x000000019da6c604 GSEventRunModal + 164 (GSEvent.c:2246)
28 UIKitCore 0x0000000197829358 UIApplicationMain + 1944 (UIApplication.m:4823)
29 [APPNAME] 0x0000000100d45128 main + 68 (CustomClass.swift:25)
30 libdyld.dylib 0x00000001934d12dc start + 4

Qt GroupedDragging crashes

I am using Qt 5.7 under MacOS Sierra, and I was experimenting with Qt's GroupedDragging in docks. However, this crashes my app a lot when I'm moving my docks around. It's quite random so I cant reproduce the error.
This is how I set my dock options:
setDockOptions(DockOptions( QMainWindow::GroupedDragging) );
I already tried enabling and disabling animations, tabbedDocks, etc, nothing seems to work.
Is there anything I can do?
This is the stacktrace:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 org.qt-project.QtWidgets 0x0000000102209fbd QLayout::activateRecursiveHelper(QLayoutItem*) + 13
1 org.qt-project.QtWidgets 0x0000000102209ff8 QLayout::activateRecursiveHelper(QLayoutItem*) + 72
2 org.qt-project.QtWidgets 0x0000000102208f76 QLayout::activate() + 102
3 org.qt-project.QtWidgets 0x00000001022282a6 QWidget::setVisible(bool) + 678
4 org.qt-project.QtWidgets 0x0000000102341fcf QMainWindowLayout::animationFinished(QWidget*) + 2447
5 org.qt-project.QtCore 0x000000010307f923 QMetaObject::activate(QObject*, int, int, void**) + 883
6 org.qt-project.QtCore 0x0000000102e70562 QAbstractAnimationPrivate::setState(QAbstractAnimation::State) + 578
7 org.qt-project.QtCore 0x0000000102e6f223 QAbstractAnimation::setCurrentTime(int) + 387
8 org.qt-project.QtCore 0x0000000102e6f058 QAnimationTimer::updateAnimationsTime(long long) + 104
9 org.qt-project.QtCore 0x0000000102e6db67 QUnifiedTimer::updateAnimationTimers(long long) + 295
10 org.qt-project.QtCore 0x0000000102e6ffec QAnimationDriver::advance() + 28
11 org.qt-project.QtCore 0x0000000103078980 QObject::event(QEvent*) + 48
12 org.qt-project.QtWidgets 0x00000001021e8edd QApplicationPrivate::notify_helper(QObject*, QEvent*) + 269
13 org.qt-project.QtWidgets 0x00000001021eb822 QApplication::notify(QObject*, QEvent*) + 5906
14 org.qt-project.QtCore 0x000000010304eaa4 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 164
15 org.qt-project.QtCore 0x00000001030a2ee6 QTimerInfoList::activateTimers() + 1142
16 libqcocoa.dylib 0x00000001056db932 QCocoaEventDispatcherPrivate::activateTimersSourceCallback(void*) + 18

How to prevent shutdown race conditions with Qt Network classes

We have an OS X C++ application, using Qt 5.5 that provides a simple HTTP server interface. It's essentially similar to the Fortune Server example provided by Qt (http://doc.qt.io/qt-5/qtnetwork-fortuneserver-example.html), but what we're seeing is that occasionally the application is seg faulting upon shutdown, with the following stack trace (thread 6 crashing):
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff8deb4fca __open + 10
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff8deb6232 kevent64 + 10
1 libdispatch.dylib 0x00007fff90f0426e _dispatch_mgr_thread + 52
Thread 2:
0 libsystem_kernel.dylib 0x00007fff8deb594a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff887833dd start_wqthread + 13
Thread 3:
0 libsystem_kernel.dylib 0x00007fff8deb594a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff887833dd start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff8deb594a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff887833dd start_wqthread + 13
Thread 5:: Dispatch queue: com.apple.NSXPCConnection.m-user.com.apple.airportd
0 libsystem_platform.dylib 0x00007fff8923378d _os_lock_handoff_lock + 23
1 libobjc.A.dylib 0x00007fff83258906 objc_object::sidetable_clearDeallocating() + 64
2 libobjc.A.dylib 0x00007fff8323e651 objc_destructInstance + 145
3 libobjc.A.dylib 0x00007fff8323e595 object_dispose + 22
4 com.apple.CoreFoundation 0x00007fff84eea448 -[__NSArrayM dealloc] + 376
5 libobjc.A.dylib 0x00007fff8325889c objc_object::sidetable_release(bool) + 236
6 com.apple.Foundation 0x00007fff85747909 -[_NSXPCInterfaceMethodInfo dealloc] + 63
7 libobjc.A.dylib 0x00007fff8325889c objc_object::sidetable_release(bool) + 236
8 com.apple.CoreFoundation 0x00007fff84ed5db0 CFRelease + 304
9 com.apple.CoreFoundation 0x00007fff84ee5b92 __CFBasicHashDrain + 498
10 com.apple.CoreFoundation 0x00007fff84ed5e8e CFRelease + 526
11 com.apple.Foundation 0x00007fff8578dd7a -[NSXPCInterface dealloc] + 28
12 libobjc.A.dylib 0x00007fff8325889c objc_object::sidetable_release(bool) + 236
13 com.apple.Foundation 0x00007fff8578df0c -[NSXPCConnection dealloc] + 281
14 libobjc.A.dylib 0x00007fff8325889c objc_object::sidetable_release(bool) + 236
15 libsystem_blocks.dylib 0x00007fff8d3166e5 _Block_release + 196
16 libdispatch.dylib 0x00007fff90effe73 _dispatch_client_callout + 8
17 libdispatch.dylib 0x00007fff90f035cd _dispatch_queue_drain + 1100
18 libdispatch.dylib 0x00007fff90f03030 _dispatch_queue_invoke + 202
19 libdispatch.dylib 0x00007fff90f02bef _dispatch_root_queue_drain + 463
20 libdispatch.dylib 0x00007fff90f02a1c _dispatch_worker_thread3 + 91
21 libsystem_pthread.dylib 0x00007fff88785a9d _pthread_wqthread + 729
22 libsystem_pthread.dylib 0x00007fff887833dd start_wqthread + 13
Thread 6 Crashed:: Qt bearer thread
0 org.qt-project.QtNetwork 0x0000000100a541cb QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() + 107
1 org.qt-project.QtNetwork 0x0000000100a5431e QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() + 14
2 org.qt-project.QtCore 0x0000000100d72427 QObject::event(QEvent*) + 823
3 org.qt-project.QtCore 0x0000000100d49588 QCoreApplication::notify(QObject*, QEvent*) + 104
4 org.qt-project.QtCore 0x0000000100d4a212 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 1058
5 org.qt-project.QtCore 0x0000000100d997db QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 59
6 org.qt-project.QtCore 0x0000000100d46c1c QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 412
7 org.qt-project.QtCore 0x0000000100b9c07e QThread::exec() + 110
8 org.qt-project.QtCore 0x0000000100b9fc02 QThreadPrivate::start(void*) + 338
9 libsystem_pthread.dylib 0x00007fff8878605a _pthread_body + 131
10 libsystem_pthread.dylib 0x00007fff88785fd7 _pthread_start + 176
11 libsystem_pthread.dylib 0x00007fff887833ed thread_start + 13
As you can see, thread 0 is done - we're outside main. I'm sure there's some cleanup code I'm failing to call when we're disposing of our resources, but I don't know what it can be.
Without putting all our source up here, the basic chain of calls were doing is:
class RestServer : public QObject {
RestServer::RestServer() {
_tcpServer = new QTcpServer(this);
}
void RestServer::listen(quint16 port)
{
if (!_tcpServer->listen(QHostAddress::LocalHost, port)) {
LOG_ERROR("RestServer", "Failed to start server at: " << port);
throw std::exception();
}
_portNum = _tcpServer->serverPort();
LOG_INFO("RestServer", "Server is listening at: " << _portNum);
connect(_tcpServer, SIGNAL(newConnection()), this, SLOT(connectSocket()));
}
Then in our test code, we basically do:
void RestAPIServer_test::responseCallback(QNetworkReply *reply)
{
auto response = reply->readAll();
_uri = response;
reply->close();
QCoreApplication::exit();
}
TEST_F(RestAPIServer_test, urlWithPercents)
{
RestServer restServer();
restServer.listen(0);
quint16 port = restServer.serverPort();
// "widget/foo bar.txt"
QUrl serviceUrl(QString("http://localhost:%1/path/?path=widget%2Ffoo%20bar.txt").arg(port));
QNetworkAccessManager networkManager(this);
connect(&networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(responseCallback(QNetworkReply*)));
QNetworkRequest request(serviceUrl);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
networkManager.get(request);
QCoreApplication::exec();
ASSERT_EQ(QString("path=widget/foo bar.txt"), _uri);
}
It is not safe to instantiate a QObject on stack with a parent. Look at the line
QNetworkAccessManager networkManager(this);
The object would be destroyed twice, which is not possible, so you see the crash. Change that line as follows (of course, the use of variable networkManager must also be updated):
QNetworkAccessManager* networkManager=new QNetworkAccessManager(this);
The problem seemed to be due to some networking-related threads created by Qt still running for a bit after the call to QCoreApplication::quit() was called, probably because the quit() was called from within the callback function registered with the QTcpSocket. The solution was to put a 1-second sleep after the call to exit:
void RestAPIServer_test::responseCallback(QNetworkReply *reply)
{
auto response = reply->readAll();
_uri = response;
reply->close();
QCoreApplication::exit();
// This prevents a shutdown race condition where Qt service
// threads continue to run after the call to exit().
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}

EXC_BAD_ACCESS - Random AND Incomprehensible

I knew EXC_BAD_ACCESS & Zombie, and how to find it in normal way. But what I face now is very very confusing, at least to me.
Background
I have a multi-account app, in which the user can login many accounts at the same time.
The app works well with only one account on, but when the user really logins more and more accounts, the app becomes more and more vulnerable as well, crashing randomly but mostly on AppLaunch. Not 8badf00d, but EXC_BAD_ACCESS (SIGSEGV) / KERN_INVALID_ADDRESS.
Code Architecture
Objective-C - Application level, including UI.
|
Objective-C & C++ - Account Context, including login logic.
|
C++ - Net/Communication level, including sockets.
Notification & Delegation are both used between levels.
Reproduce
Double-tap the Home button, swipe the app out to kill it, then tap the app icon to relaunch it. After passing TouchId, the app will login the accounts, and randomly crash, resulting in many different crash logs. No matter the device is iPhone 6s plus or iPhone 5s/5c/5, iOS 8 or iOS 9.
The memory usage is not high, just several tens of MB.
Crash Log No.1
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000100000048
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000180b8dbd0 objc_msgSend + 16
1 CoreFoundation 0x00000001814c7fe0 -[_CFXNotificationObjectRegistration match:matching:] + 152
2 CoreFoundation 0x0000000181573704 -[_CFXNotificationNameRegistration match:observer:matching:] + 372
3 CoreFoundation 0x0000000181518778 -[_CFXNotificationRegistrar match:object:observer:enumerator:] + 1968
4 CoreFoundation 0x0000000181415894 _CFXNotificationRemoveObservers + 164
5 Foundation 0x0000000181de3510 -[NSNotificationCenter removeObserver:name:object:] + 236
6 Foundation 0x0000000181df036c -[__NSObserver dealloc] + 48
7 UIKit 0x000000018639d12c -[_UIBackdropView dealloc] + 280
8 libobjc.A.dylib 0x0000000180b95ae8 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 508
9 CoreFoundation 0x00000001813f142c _CFAutoreleasePoolPop + 28
10 UIKit 0x00000001864bdf94 _prepareForCAFlush + 352
11 UIKit 0x00000001861fe8f4 _UIApplicationHandleEventQueue + 5880
12 CoreFoundation 0x00000001814c4efc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
13 CoreFoundation 0x00000001814c4910 __CFRunLoopDoSources0 + 412
14 CoreFoundation 0x00000001814c2690 __CFRunLoopRun + 724
15 CoreFoundation 0x00000001813f1680 CFRunLoopRunSpecific + 384
16 GraphicsServices 0x0000000182900088 GSEventRunModal + 180
17 UIKit 0x0000000186268d90 UIApplicationMain + 204
18 MultiAccountApp 0x0000000100095254 main (main.m:19)
19 libdyld.dylib 0x0000000180f928b8 start + 4
Thread 1:
0 libsystem_pthread.dylib 0x000000018117501c start_wqthread + 0
Thread 2 name: Dispatch queue: com.apple.libdispatch-manager
Thread 2:
0 libsystem_kernel.dylib 0x00000001810b14fc kevent_qos + 8
1 libdispatch.dylib 0x0000000180f7494c _dispatch_mgr_invoke + 232
2 libdispatch.dylib 0x0000000180f637bc _dispatch_source_invoke + 0
Crash Log No.2
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000180b7e5f4 _class_getNonMetaClass + 212
1 libobjc.A.dylib 0x0000000180b7e5f0 _class_getNonMetaClass + 208
2 libobjc.A.dylib 0x0000000180b7accc _class_resolveMethod + 112
3 libobjc.A.dylib 0x0000000180b839a8 lookUpImpOrForward + 360
4 libobjc.A.dylib 0x0000000180b837b4 class_getInstanceMethod + 64
5 Foundation 0x0000000181e1530c +[NSObject(NSKeyValueObservingCustomization) keyPathsForValuesAffectingValueForKey:] + 236
6 Foundation 0x0000000181e14ff8 -[NSKeyValueUnnestedProperty _givenPropertiesBeingInitialized:getAffectingProperties:] + 184
7 Foundation 0x0000000181e14d14 -[NSKeyValueUnnestedProperty _initWithContainerClass:key:propertiesBeingInitialized:] + 152
8 Foundation 0x0000000181e14bec NSKeyValuePropertyForIsaAndKeyPathInner + 284
9 Foundation 0x0000000181e11508 NSKeyValuePropertyForIsaAndKeyPath + 152
10 Foundation 0x0000000181e27ddc _NSKeyValueCreateImplicitObservationInfo + 248
11 CoreData 0x0000000182fa1764 -[NSManagedObjectContext(_NSInternalNotificationHandling) _implicitObservationInfoForEntity:forResultingClass:] + 300
12 CoreData 0x0000000182fa162c -[NSManagedObject(_NSInternalMethods) _implicitObservationInfo] + 96
13 Foundation 0x0000000181de2840 -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:] + 160
14 CoreData 0x0000000183002c2c -[NSManagedObject(_NSInternalMethods) _updateFromRefreshSnapshot:includingTransients:] + 628
15 CoreData 0x0000000183015b54 -[NSManagedObjectContext(_NestedContextSupport) _copyChildObject:toParentObject:fromChildContext:] + 924
16 CoreData 0x0000000183015f70 -[NSManagedObjectContext(_NestedContextSupport) _parentProcessSaveRequest:inContext:error:] + 996
17 CoreData 0x0000000183016a44 __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke + 348
18 CoreData 0x0000000183018d80 internalBlockToNSManagedObjectContextPerform + 108
19 libdispatch.dylib 0x0000000180f615f0 _dispatch_client_callout + 16
20 libdispatch.dylib 0x0000000180f70c5c _dispatch_barrier_sync_f_slow_invoke + 644
21 libdispatch.dylib 0x0000000180f615f0 _dispatch_client_callout + 16
22 libdispatch.dylib 0x0000000180f66cf8 _dispatch_main_queue_callback_4CF + 1844
23 CoreFoundation 0x00000001814c4bb0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
24 CoreFoundation 0x00000001814c2a18 __CFRunLoopRun + 1628
25 CoreFoundation 0x00000001813f1680 CFRunLoopRunSpecific + 384
26 GraphicsServices 0x0000000182900088 GSEventRunModal + 180
27 UIKit 0x0000000186268d90 UIApplicationMain + 204
28 MultiAccountApp 0x0000000100085254 main (main.m:19)
29 libdyld.dylib 0x0000000180f928b8 start + 4
Thread 1:
0 libsystem_kernel.dylib 0x00000001810b0b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000181175530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x0000000181175020 start_wqthread + 4
Thread 2 name: Dispatch queue: com.apple.libdispatch-manager
Thread 2:
0 libsystem_kernel.dylib 0x00000001810b14fc kevent_qos + 8
1 libdispatch.dylib 0x0000000180f7494c _dispatch_mgr_invoke + 232
2 libdispatch.dylib 0x0000000180f637bc _dispatch_source_invoke + 0
Crash Log No.3
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000100000038
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000180b8dbd0 objc_msgSend + 16
1 QuartzCore 0x0000000183c3bad0 CA::Render::String::new_string(__CFString const*) + 36
2 QuartzCore 0x0000000183c3c46c -[CABackdropLayer _copyRenderLayer:layerFlags:commitFlags:] + 144
3 QuartzCore 0x0000000183c0ac54 CA::Context::commit_layer(CA::Layer*, unsigned int, unsigned int, void*) + 108
4 QuartzCore 0x0000000183c079cc CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 392
5 QuartzCore 0x0000000183c0795c CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 280
6 QuartzCore 0x0000000183c0795c CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 280
7 QuartzCore 0x0000000183c0795c CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 280
8 QuartzCore 0x0000000183c0795c CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) + 280
9 QuartzCore 0x0000000183c07750 x_hash_table_foreach + 72
10 QuartzCore 0x0000000183c06cc8 CA::Transaction::foreach_root(void (*)(CA::Layer*, void*), void*) + 40
11 QuartzCore 0x0000000183c050f0 CA::Context::commit_transaction(CA::Transaction*) + 1368
12 QuartzCore 0x0000000183c049dc CA::Transaction::commit() + 512
13 UIKit 0x00000001864bde20 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke_2 + 104
14 CoreFoundation 0x00000001814c4de4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
15 CoreFoundation 0x00000001814c471c __CFRunLoopDoBlocks + 308
16 CoreFoundation 0x00000001814c26a4 __CFRunLoopRun + 744
17 CoreFoundation 0x00000001813f1680 CFRunLoopRunSpecific + 384
18 GraphicsServices 0x0000000182900088 GSEventRunModal + 180
19 UIKit 0x0000000186268d90 UIApplicationMain + 204
20 MultiAccountApp 0x000000010009d254 main (main.m:19)
21 libdyld.dylib 0x0000000180f928b8 start + 4
Crash Log No.4
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000100000048
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000180b8dbd0 objc_msgSend + 16
1 CoreFoundation 0x00000001813f93e0 -[__NSArrayM dealloc] + 152
2 libobjc.A.dylib 0x0000000180b95ae8 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 508
3 CoreFoundation 0x00000001813f142c _CFAutoreleasePoolPop + 28
4 CoreFoundation 0x00000001814c2a20 __CFRunLoopRun + 1636
5 CoreFoundation 0x00000001813f1680 CFRunLoopRunSpecific + 384
6 GraphicsServices 0x0000000182900088 GSEventRunModal + 180
7 UIKit 0x0000000186268d90 UIApplicationMain + 204
8 MultiAccountApp 0x00000001000f5254 main (main.m:19)
9 libdyld.dylib 0x0000000180f928b8 start + 4
Thread 1:
0 libsystem_kernel.dylib 0x00000001810b0b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000181175530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x0000000181175020 start_wqthread + 4
Crash Log No.5
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000100000050
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000180b8dbd0 objc_msgSend + 16
1 CoreFoundation 0x00000001814c7fe0 -[_CFXNotificationObjectRegistration match:matching:] + 152
2 CoreFoundation 0x0000000181573704 -[_CFXNotificationNameRegistration match:observer:matching:] + 372
3 CoreFoundation 0x0000000181518778 -[_CFXNotificationRegistrar match:object:observer:enumerator:] + 1968
4 CoreFoundation 0x0000000181415894 _CFXNotificationRemoveObservers + 164
5 Foundation 0x0000000181de3510 -[NSNotificationCenter removeObserver:name:object:] + 236
6 UIKit 0x00000001863a0948 -[UINavigationController dealloc] + 140
7 CoreFoundation 0x00000001813f5380 -[__NSArrayI dealloc] + 80
8 UIKit 0x00000001864b0cb4 _runAfterCACommitDeferredBlocks + 616
9 UIKit 0x00000001864be030 _cleanUpAfterCAFlushAndRunDeferredBlocks + 92
10 CoreFoundation 0x00000001814c4de4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
11 CoreFoundation 0x00000001814c471c __CFRunLoopDoBlocks + 308
12 CoreFoundation 0x00000001814c26a4 __CFRunLoopRun + 744
13 CoreFoundation 0x00000001813f1680 CFRunLoopRunSpecific + 384
14 GraphicsServices 0x0000000182900088 GSEventRunModal + 180
15 UIKit 0x0000000186268d90 UIApplicationMain + 204
16 MultiAccountApp 0x0000000100099254 main (main.m:19)
17 libdyld.dylib 0x0000000180f928b8 start + 4
Though I have logs in hand, I still have no idea how to solve it. Maybe the Address Space has been dirty? Forcibly / unintentionally modified by the C++ level?
Thanks in advance.

How to use wxTreeItemData without crashing upon deletion

I'm using wxWidgets, and I have a wxTreeCtrl set up with a root and a single child. I'm setting client data on the child and it works fine until the window closes, at which point I get a bus error, which I'm assuming is coming from wxWidgets attempting to delete my client data.
Here's my client data struct:
struct MapPtrCtr {
Map* map;
MapPtrCtr(Map* map) : map(map) {}
};
Here's how I set the client data (note that here, map is std::shared_ptr<Map>):
wxTreeItemId childNode = mapTree->AppendItem(node, map->getTitle());
mapTree->SetItemData(childNode, (wxTreeItemData*) new MapPtrCtr(map.get()));
Here's the error I get:
Process: AromatherapyMapEditor [43832]
Path: /Users/USER/*/AromatherapyMapEditor
Identifier: AromatherapyMapEditor
Version: 0
Code Type: X86-64 (Native)
Parent Process: bash [805]
Responsible: Terminal [798]
User ID: 501
Date/Time: 2015-03-16 13:38:02.964 -0400
OS Version: Mac OS X 10.10.1 (14B25)
Report Version: 11
Anonymous UUID: 3887BB6D-7783-EBA5-C86C-FACE1C21094E
Sleep/Wake UUID: 9C9670EA-BBC7-4046-B544-F1CE3F184398
Time Awake Since Boot: 84000 seconds
Time Since Wake: 12000 seconds
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007fb920f1ae80
VM Regions Near 0x7fb920f1ae80:
MALLOC_TINY 00007fb920d00000-00007fb920f00000 [ 2048K] rw-/rwx SM=PRV
--> MALLOC_TINY 00007fb920f00000-00007fb921000000 [ 1024K] rw-/rwx SM=COW
MALLOC_SMALL 00007fb921000000-00007fb921800000 [ 8192K] rw-/rwx SM=COW
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 0x00007fb920f1ae80 0 + 140433098387072
1 libwx_osx_cocoau_core-3.0.dylib 0x00000001075f6a26 wxGenericTreeItem::DeleteChildren(wxGenericTreeCtrl*) + 94
2 libwx_osx_cocoau_core-3.0.dylib 0x00000001075fabe2 wxGenericTreeCtrl::Delete(wxTreeItemId const&) + 264
3 libwx_osx_cocoau_core-3.0.dylib 0x00000001075fac64 wxGenericTreeCtrl::DeleteAllItems() + 40
4 libwx_osx_cocoau_core-3.0.dylib 0x00000001075f925c wxGenericTreeCtrl::~wxGenericTreeCtrl() + 102
5 libwx_osx_cocoau_core-3.0.dylib 0x000000010759f96b wxTreeCtrl::~wxTreeCtrl() + 15
6 libwx_osx_cocoau_core-3.0.dylib 0x00000001075a5da0 wxWindowBase::Destroy() + 40
7 libwx_osx_cocoau_core-3.0.dylib 0x00000001075a5e96 wxWindowBase::DestroyChildren() + 20
8 libwx_osx_cocoau_core-3.0.dylib 0x0000000107438d79 wxWindow::~wxWindow() + 215
9 libwx_osx_cocoau_core-3.0.dylib 0x00000001075effeb wxSplitterWindow::~wxSplitterWindow() + 15
10 libwx_osx_cocoau_core-3.0.dylib 0x00000001075a5da0 wxWindowBase::Destroy() + 40
11 libwx_osx_cocoau_core-3.0.dylib 0x00000001075a5e96 wxWindowBase::DestroyChildren() + 20
12 libwx_osx_cocoau_core-3.0.dylib 0x0000000107435121 wxNonOwnedWindow::~wxNonOwnedWindow() + 45
13 AromatherapyMapEditor 0x000000010739f913 MapeditFrame::~MapeditFrame() + 259 (frame.h:24)
14 AromatherapyMapEditor 0x000000010739e1f5 MapeditFrame::~MapeditFrame() + 21 (frame.h:24)
15 AromatherapyMapEditor 0x000000010739e219 MapeditFrame::~MapeditFrame() + 25 (frame.h:24)
16 libwx_baseu-3.0.dylib 0x000000010795ec72 wxAppConsoleBase::DeletePendingObjects() + 74
17 libwx_baseu-3.0.dylib 0x000000010795ebd3 wxAppConsoleBase::ProcessIdle() + 85
18 libwx_osx_cocoau_core-3.0.dylib 0x00000001074dcef6 wxAppBase::ProcessIdle() + 22
19 libwx_osx_cocoau_core-3.0.dylib 0x000000010746be5a wxApp::ProcessIdle() + 26
20 libwx_baseu-3.0.dylib 0x0000000107984faa wxEventLoopBase::ProcessIdle() + 28
21 libwx_baseu-3.0.dylib 0x0000000107a0d661 wxCFEventLoop::CommonModeObserverCallBack(__CFRunLoopObserver*, int) + 69
22 com.apple.CoreFoundation 0x00007fff8db02d87 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
23 com.apple.CoreFoundation 0x00007fff8db02ce0 __CFRunLoopDoObservers + 368
24 com.apple.CoreFoundation 0x00007fff8daf4f1a __CFRunLoopRun + 1178
25 com.apple.CoreFoundation 0x00007fff8daf4838 CFRunLoopRunSpecific + 296
26 com.apple.HIToolbox 0x00007fff926dd43f RunCurrentEventLoopInMode + 235
27 com.apple.HIToolbox 0x00007fff926dd1ba ReceiveNextEventCommon + 431
28 com.apple.HIToolbox 0x00007fff926dcffb _BlockUntilNextEventMatchingListInModeWithFilter + 71
29 com.apple.AppKit 0x00007fff8b6906d1 _DPSNextEvent + 964
30 com.apple.AppKit 0x00007fff8b68fe80 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
31 com.apple.AppKit 0x00007fff8b683e23 -[NSApplication run] + 594
32 libwx_osx_cocoau_core-3.0.dylib 0x00000001074bdd8c wxGUIEventLoop::OSXDoRun() + 106
33 libwx_baseu-3.0.dylib 0x0000000107a0db35 wxCFEventLoop::DoRun() + 39
34 libwx_baseu-3.0.dylib 0x0000000107984ed8 wxEventLoopBase::Run() + 88
35 libwx_baseu-3.0.dylib 0x000000010795ea04 wxAppConsoleBase::MainLoop() + 128
36 libwx_osx_cocoau_core-3.0.dylib 0x000000010746bea8 wxApp::OnRun() + 26
37 libwx_baseu-3.0.dylib 0x00000001079b33ae wxEntry(int&, wchar_t**) + 71
38 AromatherapyMapEditor 0x000000010738d706 main + 38 (main.cpp:15)
39 libdyld.dylib 0x00007fff916bf5c9 start + 1
Any suggestions? I'm not sure how to properly use wxTreeItemData because there's very little documentation on it. The docs say to make sure to initialize the struct with new, and I do, so I'm not sure why there's a problem.
That was quick. I figured out how to properly use wxTreeItemData: you have to subclass it, not just cast to it. The following client data class works:
class MapPtrCtr : public wxTreeItemData {
public:
Map* map;
MapPtrCtr(Map* map) : map(map) {}
};