用户手动结束App时,C++代码未处理崩溃或处理崩溃的代码与系统捕获崩溃的代码冲突
苹果开发者论坛问题链接
Right. This highlights an interesting quirk with the remove-from-the-multitasking-UI gesture. If the app is suspended in the background, it simply removes it from memory. If, however, the app is running, it attempts to cleanly terminate it. For example,
<pre style="margin: 0.8em 0px 0px; padding: 0px; font-size: 16px; font-weight: 400; font-style: normal; line-height: 1.33; tab-size: 4; word-break: break-word; color: rgb(51, 51, 51); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: -0.078px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">applicationWillTerminate(_:)
</pre>
gets called in that case. It seems that your app has a bug that’s triggered by termination attempt.
Looking at your crash report I see two relevant things:
-
Your main thread is calling C++ finalisers (frame 15), and specifically the finaliser for
CConnClient
.
The crashing thread (thread 2) has crashed because of unhandled language exception.
Normally the second point would result in a Last Exception Background section in the crash report, but that only happens for Objective-C exceptions and the first point suggests that this is actually a C++ exception. That’s further confirmed by this:
libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
You need to investigate what
CConnClient
is doing on exit.
In most cases you can fix problems like this by simply removing the finaliser. After all, the entire process is going away Real Soon Now, so all that code to clean up is probably pointless.
Share and Enjoy