Solved Crash when closing app (Mac)
-
I am having a few user having crash when they close the application.
I suspect it is related to this destructor no correctly stopping the thread.
Is there a way to force thread to stop so I can avoid user having error when closing the app?
Note; inside the hub class, there is another thread "DSI_THREAD_ID uiDSIThread;"MainWindow::~MainWindow() { delete ui; for (int i=0; i<vecThread.size(); i++) { qDebug() << "Stopping this thread.." << i; QThread *thread = vecThread.at(i); thread->quit(); thread->wait(); } }
Here is how the threads are started:
QThread *thread = new QThread; Hub *hub = new Hub(numberInitStickDone); hub->moveToThread(thread); vecHub.append(hub); vecThread.append(thread); connect(thread, SIGNAL(finished()), hub, SLOT(deleteLater()) ); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); thread->start();
Here is the crash log
Process: MaximumTrainer [72356] Path: /Applications/MaximumTrainer.app/Contents/MacOS/MaximumTrainer Identifier: com.yourcompany.MaximumTrainer Version: 0 Code Type: X86-64 (Native) Parent Process: ??? [1] Responsible: MaximumTrainer [72356] User ID: 501 Date/Time: 2017-02-24 12:45:42.638 -0500 OS Version: Mac OS X 10.11.6 (15G1217) Time Awake Since Boot: 660000 seconds Time Since Wake: 680 seconds System Integrity Protection: enabled Crashed Thread: 13 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000137 Exception Note: EXC_CORPSE_NOTIFY Thread 0:: CrBrowserMain Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x00007fff8923ddb6 __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff8927f728 _pthread_cond_wait + 767 2 org.qt-project.QtCore 0x0000000106bd203f 0x106ba6000 + 180287 3 org.qt-project.QtCore 0x0000000106bd1e7b 0x106ba6000 + 179835 4 org.qt-project.QtCore 0x0000000106bd1d42 QWaitCondition::wait(QMutex*, unsigned long) + 162 5 org.qt-project.QtCore 0x0000000106bd150e QThread::wait(unsigned long) + 110 6 org.qt-project.QtNetwork 0x0000000106adddec QNetworkConfigurationManagerPrivate::cleanup() + 28 7 org.qt-project.QtCore 0x0000000106d8f71e qt_call_post_routines() + 46 8 org.qt-project.QtWidgets 0x00000001076d40d5 QApplication::~QApplication() + 37 9 com.yourcompany.MaximumTrainer 0x0000000100d38344 main + 420 10 libdyld.dylib 0x00007fff8b8e85ad start + 1 Thread 1: 0 libsystem_kernel.dylib 0x00007fff8923e5e2 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff8927e578 _pthread_wqthread + 1283 2 libsystem_pthread.dylib 0x00007fff8927c341 start_wqthread + 13 Thread 2:: Dispatch queue: com.apple.libdispatch-manager 0 libsystem_kernel.dylib 0x00007fff8923eefa kevent_qos + 10 1 libdispatch.dylib 0x00007fff920494fe _dispatch_kq_update + 136 2 libdispatch.dylib 0x00007fff9204fb2c _dispatch_timers_program + 924 3 libdispatch.dylib 0x00007fff9204b101 _dispatch_mgr_invoke + 116 4 libdispatch.dylib 0x00007fff9204adcd _dispatch_mgr_thread + 52 Thread 3: 0 libsystem_kernel.dylib 0x00007fff8923e5e2 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff8927e578 _pthread_wqthread + 1283 2 libsystem_pthread.dylib 0x00007fff8927c341 start_wqthread + 13 Thread 4: 0 libsystem_kernel.dylib 0x00007fff8923e5e2 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff8927e578 _pthread_wqthread + 1283 2 libsystem_pthread.dylib 0x00007fff8927c341 start_wqthread + 13 Thread 5: 0 libsystem_pthread.dylib 0x00007fff8927c334 start_wqthread + 0 Thread 6: 0 libsystem_kernel.dylib 0x00007fff8923e5e2 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff8927e578 _pthread_wqthread + 1283 2 libsystem_pthread.dylib 0x00007fff8927c341 start_wqthread + 13 Thread 7:: Qt bearer thread 0 libsystem_kernel.dylib 0x00007fff8923ddb6 __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff8927f728 _pthread_cond_wait + 767 2 org.qt-project.QtCore 0x0000000106bd1e9b 0x106ba6000 + 179867 3 org.qt-project.QtCore 0x0000000106bd1d42 QWaitCondition::wait(QMutex*, unsigned long) + 162 4 org.qt-project.QtCore 0x0000000106bd150e QThread::wait(unsigned long) + 110 5 libqcorewlanbearer.dylib 0x000000010e34e6a8 0x10e344000 + 42664 6 libqcorewlanbearer.dylib 0x000000010e34e7fe 0x10e344000 + 43006 7 org.qt-project.QtNetwork 0x0000000106addc3e QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() + 110 8 org.qt-project.QtNetwork 0x0000000106adddbe QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() + 14 9 org.qt-project.QtCore 0x0000000106dbc627 QObject::event(QEvent*) + 823 10 org.qt-project.QtCore 0x0000000106d9295f QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) + 303 11 org.qt-project.QtCore 0x0000000106d92559 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 185 12 org.qt-project.QtCore 0x0000000106d931c8 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 600 13 org.qt-project.QtCore 0x0000000106de5c49 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 73 14 org.qt-project.QtCore 0x0000000106d8e781 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 401 15 org.qt-project.QtCore 0x0000000106bcceee QThread::exec() + 110 16 org.qt-project.QtCore 0x0000000106bd085a 0x106ba6000 + 174170 17 libsystem_pthread.dylib 0x00007fff8927e99d _pthread_body + 131 18 libsystem_pthread.dylib 0x00007fff8927e91a _pthread_start + 168 19 libsystem_pthread.dylib 0x00007fff8927c351 thread_start + 13 Thread 8:: Thread (pooled) 0 libsystem_kernel.dylib 0x00007fff8923ddb6 __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff8927f728 _pthread_cond_wait + 767 2 org.qt-project.QtCore 0x0000000106bd203f 0x106ba6000 + 180287 3 org.qt-project.QtCore 0x0000000106bd1e7b 0x106ba6000 + 179835 4 org.qt-project.QtCore 0x0000000106bd1d42 QWaitCondition::wait(QMutex*, unsigned long) + 162 5 org.qt-project.QtCore 0x0000000106bcd8fe 0x106ba6000 + 162046 6 org.qt-project.QtCore 0x0000000106bd085a 0x106ba6000 + 174170 7 libsystem_pthread.dylib 0x00007fff8927e99d _pthread_body + 131 8 libsystem_pthread.dylib 0x00007fff8927e91a _pthread_start + 168 9 libsystem_pthread.dylib 0x00007fff8927c351 thread_start + 13 Thread 9:: com.apple.NSEventThread 0 libsystem_kernel.dylib 0x00007fff89237f72 mach_msg_trap + 10 1 libsystem_kernel.dylib 0x00007fff892373b3 mach_msg + 55 2 com.apple.CoreFoundation 0x00007fff9846a124 __CFRunLoopServiceMachPort + 212 3 com.apple.CoreFoundation 0x00007fff984695ec __CFRunLoopRun + 1356 4 com.apple.CoreFoundation 0x00007fff98468e38 CFRunLoopRunSpecific + 296 5 com.apple.AppKit 0x00007fff86620d95 _NSEventThread + 149 6 libsystem_pthread.dylib 0x00007fff8927e99d _pthread_body + 131 7 libsystem_pthread.dylib 0x00007fff8927e91a _pthread_start + 168 8 libsystem_pthread.dylib 0x00007fff8927c351 thread_start + 13 Thread 10: 0 libsystem_kernel.dylib 0x00007fff8923e5e2 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff8927e578 _pthread_wqthread + 1283 2 libsystem_pthread.dylib 0x00007fff8927c341 start_wqthread + 13 Thread 11:: CachePoolWorker1/101659 0 libsystem_kernel.dylib 0x00007fff8923ddb6 __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff8927f728 _pthread_cond_wait + 767 2 org.qt-project.Qt.QtWebEngineCore 0x00000001027c6d47 0x1014b4000 + 20000071 3 org.qt-project.Qt.QtWebEngineCore 0x00000001027c63dd 0x1014b4000 + 19997661 4 org.qt-project.Qt.QtWebEngineCore 0x00000001027c94c8 0x1014b4000 + 20010184 5 org.qt-project.Qt.QtWebEngineCore 0x00000001027c5cc7 0x1014b4000 + 19995847 6 libsystem_pthread.dylib 0x00007fff8927e99d _pthread_body + 131 7 libsystem_pthread.dylib 0x00007fff8927e91a _pthread_start + 168 8 libsystem_pthread.dylib 0x00007fff8927c351 thread_start + 13 Thread 12:: CachePoolWorker2/102147 0 libsystem_kernel.dylib 0x00007fff8923ddb6 __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff8927f728 _pthread_cond_wait + 767 2 org.qt-project.Qt.QtWebEngineCore 0x00000001027c6d47 0x1014b4000 + 20000071 3 org.qt-project.Qt.QtWebEngineCore 0x00000001027c63dd 0x1014b4000 + 19997661 4 org.qt-project.Qt.QtWebEngineCore 0x00000001027c94c8 0x1014b4000 + 20010184 5 org.qt-project.Qt.QtWebEngineCore 0x00000001027c5cc7 0x1014b4000 + 19995847 6 libsystem_pthread.dylib 0x00007fff8927e99d _pthread_body + 131 7 libsystem_pthread.dylib 0x00007fff8927e91a _pthread_start + 168 8 libsystem_pthread.dylib 0x00007fff8927c351 thread_start + 13 Thread 13 Crashed: 0 com.yourcompany.MaximumTrainer 0x0000000100e02a8e Hub::MessageThread() + 78 1 com.yourcompany.MaximumTrainer 0x0000000100dfec89 Hub::RunMessageThread(void*) + 9 2 libsystem_pthread.dylib 0x00007fff8927e99d _pthread_body + 131 3 libsystem_pthread.dylib 0x00007fff8927e91a _pthread_start + 168 4 libsystem_pthread.dylib 0x00007fff8927c351 thread_start + 13 Thread 14:: CachePoolWorker3/134675 0 libsystem_kernel.dylib 0x00007fff8923ddb6 __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff8927f728 _pthread_cond_wait + 767 2 org.qt-project.Qt.QtWebEngineCore 0x00000001027c6d47 0x1014b4000 + 20000071 3 org.qt-project.Qt.QtWebEngineCore 0x00000001027c63dd 0x1014b4000 + 19997661 4 org.qt-project.Qt.QtWebEngineCore 0x00000001027c94c8 0x1014b4000 + 20010184 5 org.qt-project.Qt.QtWebEngineCore 0x00000001027c5cc7 0x1014b4000 + 19995847 6 libsystem_pthread.dylib 0x00007fff8927e99d _pthread_body + 131 7 libsystem_pthread.dylib 0x00007fff8927e91a _pthread_start + 168 8 libsystem_pthread.dylib 0x00007fff8927c351 thread_start + 13 Thread 15:: QScanThread 0 libsystem_kernel.dylib 0x00007fff89237fae semaphore_wait_trap + 10 1 libdispatch.dylib 0x00007fff92050cb2 _dispatch_semaphore_wait_slow + 224 2 com.apple.framework.CoreWLAN 0x00007fff842c501b -[CWInterface(Private) scanForNetworksWithChannels:ssidList:legacyScanSSID:includeHiddenNetworks:mergedScanResults:maxAge:maxMissCount:maxWakeCount:maxAutoJoinCount:waitForWiFi:waitForBluetooth:priority:error:] + 635 3 com.apple.framework.CoreWLAN 0x00007fff842bf887 -[CWInterface scanForNetworksWithName:error:] + 109 4 libqcorewlanbearer.dylib 0x000000010e34ae69 0x10e344000 + 28265 5 org.qt-project.QtCore 0x0000000106bd085a 0x106ba6000 + 174170 6 libsystem_pthread.dylib 0x00007fff8927e99d _pthread_body + 131 7 libsystem_pthread.dylib 0x00007fff8927e91a _pthread_start + 168 8 libsystem_pthread.dylib 0x00007fff8927c351 thread_start + 13 Thread 13 crashed with X86 Thread State (64-bit): rax: 0x000000000000fffe rbx: 0x00007fc329b2d200 rcx: 0x0000730000007403 rdx: 0x0000740000007400 rdi: 0x0000000000000137 rsi: 0x0000000000012068 rbp: 0x000070000a982ee0 rsp: 0x000070000a982e70 r8: 0x0000000000000040 r9: 0x0000000115b4a140 r10: 0xffffffffffffffff r11: 0x0000000000000201 r12: 0x00000000000008ff r13: 0x000000000002050b r14: 0x000070000a982ea0 r15: 0x0000000100dfec80 rip: 0x0000000100e02a8e rfl: 0x0000000000010282 cr2: 0x00007fc329713398
-
Hi,
Are you doing any special stuff in your
Hub
destructor ? -
Hey SGaist,
No the destructor is not used.
But before closing the hub thread, this code is executed:
I suspect this code is not finished before I try to close this thread.
Thanks for the helpvoid Hub::close() { // Reset system qDebug() << "Resetting module..."; pclMessageObject->ResetSystem(); DSIThread_Sleep(1000); //Wait for test to be done DSIThread_MutexLock(&mutexTestDone); // UCHAR ucWaitResult = DSIThread_CondTimedWait(&condTestDone, &mutexTestDone, DSI_THREAD_INFINITE); // assert(ucWaitResult == DSI_THREAD_ENONE); DSIThread_MutexUnlock(&mutexTestDone); //Destroy mutex and condition var DSIThread_MutexDestroy(&mutexTestDone); DSIThread_CondDestroy(&condTestDone); //Close all stuff if(pclSerialObject) pclSerialObject->Close(); #if defined(DEBUG_FILE) DSIDebug::Close(); #endif }
-
@maximus said in Crash when closing app (Mac):
0 com.yourcompany.MaximumTrainer 0x0000000100e02a8e Hub::MessageThread() + 78
The crash is there.. what is that code doing at that time?
Oh and to answer your question you can terminate your threads but that leaves your app in a bad state a lot of times. I would figure out your crash and not just move to
terminate
. -
Thanks for the help with the log fire ambershark.
The messageThread was still running.
I guess I should emit a signal when it is finished to run before closing the app.
It was not causing problem but giving user error on shutdown.Cheers,
Max -
Indeed, you should always ensure that you thread are ended gracefully unless there's no other choice but you should always avoid terminating a thread.
-
I have the same issue again but now it appears to be Qt lib in cause?
Process: MaximumTrainer [75036]
Path: /Applications/MaximumTrainer.app/Contents/MacOS/MaximumTrainer
Identifier: com.yourcompany.MaximumTrainer
Version: 0
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: MaximumTrainer [75036]
User ID: 501Date/Time: 2017-03-19 17:25:43.388 -0400
OS Version: Mac OS X 10.11.6 (15G1217)
Report Version: 11
Anonymous UUID: 55EE391A-1E7D-1FA3-33DA-B6997647DD0DSleep/Wake UUID: AA81F045-0E2E-4C66-8C5A-42FC65C58097
Time Awake Since Boot: 570000 seconds
Time Since Wake: 620 secondsSystem Integrity Protection: enabled
Crashed Thread: 8
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT
Exception Note: EXC_CORPSE_NOTIFYThread 0:: CrBrowserMain Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff9dbeedb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8e588728 _pthread_cond_wait + 767
2 org.qt-project.QtCore 0x0000000107f5f03f 0x107f33000 + 180287
3 org.qt-project.QtCore 0x0000000107f5ee7b 0x107f33000 + 179835
4 org.qt-project.QtCore 0x0000000107f5ed42 QWaitCondition::wait(QMutex*, unsigned long) + 162
5 org.qt-project.QtCore 0x0000000107f5e50e QThread::wait(unsigned long) + 110
6 org.qt-project.QtNetwork 0x0000000107e65dec QNetworkConfigurationManagerPrivate::cleanup() + 28
7 org.qt-project.QtCore 0x000000010811c71e qt_call_post_routines() + 46
8 org.qt-project.QtWidgets 0x0000000108a5f0d5 QApplication::~QApplication() + 37
9 com.yourcompany.MaximumTrainer 0x00000001020ca434 main + 420
10 libdyld.dylib 0x00007fff8b1495ad start + 1Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff9dbefefa kevent_qos + 10
1 libdispatch.dylib 0x00007fff923bc165 _dispatch_mgr_invoke + 216
2 libdispatch.dylib 0x00007fff923bbdcd _dispatch_mgr_thread + 52Thread 2:: Qt bearer thread
0 libsystem_kernel.dylib 0x00007fff9dbeedb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8e588728 _pthread_cond_wait + 767
2 org.qt-project.QtCore 0x0000000107f5ee9b 0x107f33000 + 179867
3 org.qt-project.QtCore 0x0000000107f5ed42 QWaitCondition::wait(QMutex*, unsigned long) + 162
4 org.qt-project.QtCore 0x0000000107f5e50e QThread::wait(unsigned long) + 110
5 libqcorewlanbearer.dylib 0x000000010f6866a8 0x10f67c000 + 42664
6 libqcorewlanbearer.dylib 0x000000010f6867fe 0x10f67c000 + 43006
7 org.qt-project.QtNetwork 0x0000000107e65c3e QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() + 110
8 org.qt-project.QtNetwork 0x0000000107e65dbe QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() + 14
9 org.qt-project.QtCore 0x0000000108149627 QObject::event(QEvent*) + 823
10 org.qt-project.QtCore 0x000000010811f95f QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) + 303
11 org.qt-project.QtCore 0x000000010811f559 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 185
12 org.qt-project.QtCore 0x00000001081201c8 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 600
13 org.qt-project.QtCore 0x0000000108172c49 QEventDispatcherUNIX::processEvents(QFlagsQEventLoop::ProcessEventsFlag) + 73
14 org.qt-project.QtCore 0x000000010811b781 QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) + 401
15 org.qt-project.QtCore 0x0000000107f59eee QThread::exec() + 110
16 org.qt-project.QtCore 0x0000000107f5d85a 0x107f33000 + 174170
17 libsystem_pthread.dylib 0x00007fff8e58799d _pthread_body + 131
18 libsystem_pthread.dylib 0x00007fff8e58791a _pthread_start + 168
19 libsystem_pthread.dylib 0x00007fff8e585351 thread_start + 13Thread 3:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x00007fff9dbe8f72 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff9dbe83b3 mach_msg + 55
2 com.apple.CoreFoundation 0x00007fff8e95c124 __CFRunLoopServiceMachPort + 212
3 com.apple.CoreFoundation 0x00007fff8e95b5ec __CFRunLoopRun + 1356
4 com.apple.CoreFoundation 0x00007fff8e95ae38 CFRunLoopRunSpecific + 296
5 com.apple.AppKit 0x00007fff90d33d95 _NSEventThread + 149
6 libsystem_pthread.dylib 0x00007fff8e58799d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8e58791a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff8e585351 thread_start + 13Thread 4:: CachePoolWorker1/103687
0 libsystem_kernel.dylib 0x00007fff9dbeedb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8e588728 _pthread_cond_wait + 767
2 org.qt-project.Qt.QtWebEngineCore 0x0000000103b58d47 0x102846000 + 20000071
3 org.qt-project.Qt.QtWebEngineCore 0x0000000103b583dd 0x102846000 + 19997661
4 org.qt-project.Qt.QtWebEngineCore 0x0000000103b5b4c8 0x102846000 + 20010184
5 org.qt-project.Qt.QtWebEngineCore 0x0000000103b57cc7 0x102846000 + 19995847
6 libsystem_pthread.dylib 0x00007fff8e58799d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8e58791a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff8e585351 thread_start + 13Thread 5:: CachePoolWorker2/104195
0 libsystem_kernel.dylib 0x00007fff9dbeedb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8e588728 _pthread_cond_wait + 767
2 org.qt-project.Qt.QtWebEngineCore 0x0000000103b58d47 0x102846000 + 20000071
3 org.qt-project.Qt.QtWebEngineCore 0x0000000103b583dd 0x102846000 + 19997661
4 org.qt-project.Qt.QtWebEngineCore 0x0000000103b5b4c8 0x102846000 + 20010184
5 org.qt-project.Qt.QtWebEngineCore 0x0000000103b57cc7 0x102846000 + 19995847
6 libsystem_pthread.dylib 0x00007fff8e58799d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8e58791a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff8e585351 thread_start + 13Thread 6:: CachePoolWorker3/104707
0 libsystem_kernel.dylib 0x00007fff9dbeedb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8e588728 _pthread_cond_wait + 767
2 org.qt-project.Qt.QtWebEngineCore 0x0000000103b58d47 0x102846000 + 20000071
3 org.qt-project.Qt.QtWebEngineCore 0x0000000103b583dd 0x102846000 + 19997661
4 org.qt-project.Qt.QtWebEngineCore 0x0000000103b5b4c8 0x102846000 + 20010184
5 org.qt-project.Qt.QtWebEngineCore 0x0000000103b57cc7 0x102846000 + 19995847
6 libsystem_pthread.dylib 0x00007fff8e58799d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8e58791a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff8e585351 thread_start + 13Thread 7:: CachePoolWorker4/105219
0 libsystem_kernel.dylib 0x00007fff9dbeedb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8e588728 _pthread_cond_wait + 767
2 org.qt-project.Qt.QtWebEngineCore 0x0000000103b58d47 0x102846000 + 20000071
3 org.qt-project.Qt.QtWebEngineCore 0x0000000103b583dd 0x102846000 + 19997661
4 org.qt-project.Qt.QtWebEngineCore 0x0000000103b5b4c8 0x102846000 + 20010184
5 org.qt-project.Qt.QtWebEngineCore 0x0000000103b57cc7 0x102846000 + 19995847
6 libsystem_pthread.dylib 0x00007fff8e58799d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8e58791a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff8e585351 thread_start + 13Thread 8 Crashed:
0 com.yourcompany.MaximumTrainer 0x0000000102194686 Hub::MessageThread() + 86
1 com.yourcompany.MaximumTrainer 0x0000000102190879 Hub::RunMessageThread(void*) + 9
2 libsystem_pthread.dylib 0x00007fff8e58799d _pthread_body + 131
3 libsystem_pthread.dylib 0x00007fff8e58791a _pthread_start + 168
4 libsystem_pthread.dylib 0x00007fff8e585351 thread_start + 13Thread 9:
0 libsystem_kernel.dylib 0x00007fff9dbef5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e587578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8e585341 start_wqthread + 13Thread 10:
0 libsystem_kernel.dylib 0x00007fff9dbef5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e587578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8e585341 start_wqthread + 13Thread 11:
0 libsystem_kernel.dylib 0x00007fff9dbef5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e587578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8e585341 start_wqthread + 13Thread 12:
0 libsystem_kernel.dylib 0x00007fff9dbef5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e587578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8e585341 start_wqthread + 13Thread 13:
0 libsystem_kernel.dylib 0x00007fff9dbef5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e587578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8e585341 start_wqthread + 13Thread 14:: QScanThread
0 libsystem_kernel.dylib 0x00007fff9dbe8fae semaphore_wait_trap + 10
1 libdispatch.dylib 0x00007fff923c1cb2 _dispatch_semaphore_wait_slow + 224
2 com.apple.framework.CoreWLAN 0x00007fff9d38201b -[CWInterface(Private) scanForNetworksWithChannels:ssidList:legacyScanSSID:includeHiddenNetworks:mergedScanResults:maxAge:maxMissCount:maxWakeCount:maxAutoJoinCount:waitForWiFi:waitForBluetooth:priority:error:] + 635
3 com.apple.framework.CoreWLAN 0x00007fff9d37c887 -[CWInterface scanForNetworksWithName:error:] + 109
4 libqcorewlanbearer.dylib 0x000000010f682e69 0x10f67c000 + 28265
5 org.qt-project.QtCore 0x0000000107f5d85a 0x107f33000 + 174170
6 libsystem_pthread.dylib 0x00007fff8e58799d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8e58791a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff8e585351 thread_start + 13Thread 15:: Thread (pooled)
0 libsystem_kernel.dylib 0x00007fff9dbeedb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8e588728 _pthread_cond_wait + 767
2 org.qt-project.QtCore 0x0000000107f5f03f 0x107f33000 + 180287
3 org.qt-project.QtCore 0x0000000107f5ee7b 0x107f33000 + 179835
4 org.qt-project.QtCore 0x0000000107f5ed42 QWaitCondition::wait(QMutex*, unsigned long) + 162
5 org.qt-project.QtCore 0x0000000107f5a8fe 0x107f33000 + 162046
6 org.qt-project.QtCore 0x0000000107f5d85a 0x107f33000 + 174170
7 libsystem_pthread.dylib 0x00007fff8e58799d _pthread_body + 131
8 libsystem_pthread.dylib 0x00007fff8e58791a _pthread_start + 168
9 libsystem_pthread.dylib 0x00007fff8e585351 thread_start + 13Thread 16:
0 libsystem_kernel.dylib 0x00007fff9dbef5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e587578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8e585341 start_wqthread + 13Thread 8 crashed with X86 Thread State (64-bit):
rax: 0x001dffff7a638ce1 rbx: 0x00007ff7922ea200 rcx: 0x001a8f00001a9003 rdx: 0x0000000000000000
rdi: 0x00007ff791e06370 rsi: 0x000070000ba0bea0 rbp: 0x000070000ba0bee0 rsp: 0x000070000ba0be70
r8: 0x0000000000000040 r9: 0x0000000116daa140 r10: 0xffffffffffffffff r11: 0x0000000000000201
r12: 0x00000000000008ff r13: 0x0000000000020217 r14: 0x000070000ba0bea0 r15: 0x0000000102190870
rip: 0x0000000102194686 rfl: 0x0000000000010246 cr2: 0x00001ef96e8a0000Logical CPU: 1
Error Code: 0x00000000
Trap Number: 13Binary Images:
..
Model: MacBookPro11,1, BootROM MBP111.0138.B17, 2 processors, Intel Core i5, 2.6 GHz, 8 GB, SMC 2.16f68
Graphics: Intel Iris, Intel Iris, Built-In
Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1600 MHz, 0x02FE, -
Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1600 MHz, 0x02FE, -
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x112), Broadcom BCM43xx 1.0 (7.21.95.175.1a6)
Bluetooth: Version 4.4.6f1 17910, 3 services, 18 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
Serial ATA Device: APPLE SSD SD0128F, 121.33 GB
USB Device: USB 3.0 Bus
USB Device: Apple Internal Keyboard / Trackpad
USB Device: BRCM20702 Hub
USB Device: Bluetooth USB Host Controller
USB Device: ANT USB-m Stick
Thunderbolt Bus: MacBook Pro, Apple Inc., 17.2 -
What's in RunMessageThread ?
-
@maximus said in Crash when closing app (Mac):
0 com.yourcompany.MaximumTrainer 0x0000000102194686 Hub::MessageThread() + 86
1 com.yourcompany.MaximumTrainer 0x0000000102190879 Hub::RunMessageThread(void*) + 9If possible, can we see the code for these 2 functions? This seems like a different bug since it is a crash while starting a thread.
The crash is in Hub::MessageThread().
-
Hey sorry for the delay guys
Here is the code, It was taken from ANT+ public source code but I can modify it
It crashes only on Mac on shutdown, and not all the time (the crash doesn't cause any problem) so I am just trying to get rid of it. seems like it could be platform dependentvoid Hub::MessageThread() { ANT_MESSAGE stMessage; USHORT usSize; while(true) { if(pclMessageObject->WaitForMessage(1000)) { usSize = pclMessageObject->GetMessage(&stMessage); if(usSize == DSI_FRAMER_ERROR) { // Get the message to clear the error usSize = pclMessageObject->GetMessage(&stMessage, MESG_MAX_SIZE_VALUE); continue; } if(usSize != DSI_FRAMER_ERROR && usSize != DSI_FRAMER_TIMEDOUT && usSize != 0) { ProcessMessage(stMessage, usSize); } } } qDebug() << "End messageThread"; DSIThread_MutexLock(&mutexTestDone); UCHAR ucCondResult = DSIThread_CondSignal(&condTestDone); assert(ucCondResult == DSI_THREAD_ENONE); Q_UNUSED(ucCondResult) DSIThread_MutexUnlock(&mutexTestDone); }
I added this code to wait for Hub to close before closing the app
void MainWindow::closeEvent(QCloseEvent *event) { emit signal_hubCloseChannelCSM(closeShop); //do other stuff here before checking all hub are closed, code removed if (closedCSMFinishedNb != vecHub.size()) { qDebug() << "MainWindow, Wait for hub to close.."; timerCloseCsm.setSingleShot(true); QEventLoop loop2; timerCloseCsm.start(10000); QObject::connect(&timerCloseCsm, SIGNAL(timeout()), &loop2, SLOT(quit())); loop2.exec(); } } void MainWindow::closedCSMFinished() { qDebug() << "closedCSMFinished" << closedCSMFinishedNb; closedCSMFinishedNb++; qDebug() << "how many already closed?" << closedCSMFinishedNb << " hub size is " << vecHub.size(); if (closedCSMFinishedNb == vecHub.size()) { qDebug() << "force timerToShoot timeout"; timerCloseCsm.setInterval(0); } }
void Hub::closeScanningModeChannel(bool closeShop) { bStatus = pclMessageObject->CloseChannel(0); bStatus = pclMessageObject->UnAssignChannel(0); emit closeCSMFinished(); }
-
@maximus I have to admit I kind of lost my train of thought on this one since it's been so long.
Can you get it to crash in a debugger to get a stack trace perchance? That would help a bit.
My guess is the thread is being killed while in
pclMessageObject->WaitForMessage(1000)
and that is causing the crash. Total guess though. And with the added code waiting on close does that stop the crash?