CPPExceptionTerminate crash in iOS

Hi,

In Xcode organiser we are seeing below crash as the top most crash. We could not conclude anything with the call stack that is available. This crash is bumping our crash rates in app store connect significantly. Can someone help to figure out the root cause for this crash?

Thread 0 Crashed:
0   libsystem_kernel.dylib        	0x00000001fc4e9b78 __pthread_kill + 8
1   libsystem_pthread.dylib       	0x0000000235b083bc pthread_kill + 268 (pthread.c:1668)
2   libsystem_c.dylib             	0x00000001cfcb444c __abort + 128 (abort.c:155)
3   libsystem_c.dylib             	0x00000001cfc5c528 abort + 180 (abort.c:126)
4   libc++abi.dylib               	0x00000001dd8e9b7c abort_message + 132 (abort_message.cpp:78)
5   libc++abi.dylib               	0x00000001dd8d99c4 demangling_terminate_handler() + 336 (cxa_default_handlers.cpp:71)
6   libobjc.A.dylib               	0x00000001dd7e4c98 _objc_terminate() + 160 (objc-exception.mm:704)
7   UnityFramework                	0x00000001077acab0 CPPExceptionTerminate() + 496 (BSG_KSCrashSentry_CPPException.mm:192)
8   libc++abi.dylib               	0x00000001dd8e8f18 std::__terminate(void (*)()) + 20 (cxa_handlers.cpp:59)
9   libc++abi.dylib               	0x00000001dd8e8eb4 std::terminate() + 64 (cxa_handlers.cpp:88)
10  libdispatch.dylib             	0x00000001c47e0a40 _dispatch_client_callout + 40 (object.m:563)
11  libdispatch.dylib             	0x00000001c47e44e0 _dispatch_block_invoke_direct + 264 (queue.c:501)
12  FrontBoardServices            	0x00000001d6cdac70 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48 (FBSSerialQueue.m:157)
13  FrontBoardServices            	0x00000001d6cda040 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 220 (FBSSerialQueue.m:181)
14  FrontBoardServices            	0x00000001d6cde700 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 (FBSSerialQueue.m:194)
15  CoreFoundation                	0x00000001c4b9bf04 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1972)
16  CoreFoundation                	0x00000001c4bacc90 __CFRunLoopDoSource0 + 208 (CFRunLoop.c:2016)
17  CoreFoundation                	0x00000001c4ae6184 __CFRunLoopDoSources0 + 268 (CFRunLoop.c:2053)
18  CoreFoundation                	0x00000001c4aebb4c __CFRunLoopRun + 828 (CFRunLoop.c:2951)
19  CoreFoundation                	0x00000001c4aff6b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
20  GraphicsServices              	0x00000001e0b99374 GSEventRunModal + 164 (GSEvent.c:2200)
21  UIKitCore                     	0x00000001c7464e88 -[UIApplication _run] + 1100 (UIApplication.m:3511)
22  UIKitCore                     	0x00000001c71e65ec UIApplicationMain + 364 (UIApplication.m:5064)
23  UnityFramework                	0x0000000106054c9c -[UnityFramework runUIApplicationMainWithArgc:argv:] + 108 (main.mm:124)
24  MyGame            	            0x0000000104c916a0 main + 22176 (main.mm:28)
25  dyld                          	0x000000010567dce4 start + 520 (dyldMain.cpp:879)
[2022-03-29_20-00-15.8116_-0700-583a4bdd5502a8b86aae9cb5839c125273fdb427.crash](https://developer.apple.com/forums/content/attachment/eccc16fc-dc3b-4c62-962b-e3aa27e91418)

Can someone help to figure out the root cause for this crash?

Please post a full crash report. For instructions on that, see Posting a Crash Report.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for the crash report.

Consider this:

Exception Type:  EXC_CRASH (SIGABRT)

It suggests that your app crash itself by calling abort. And the backtrace of the crashing thread confirms that:

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib  … __pthread_kill + 8
1   libsystem_pthread.dylib … pthread_kill + 268 (pthread.c:1668)
2   libsystem_c.dylib       … __abort + 128 (abort.c:155)
3   libsystem_c.dylib       … abort + 180 (abort.c:126)
4   libc++abi.dylib         … abort_message + 132 (abort_message.cpp:78)
5   libc++abi.dylib         … demangling_terminate_handler() + 336 (cxa_default_handlers.cpp:71)
6   libobjc.A.dylib         … _objc_terminate() + 160 (objc-exception.mm:704)
7   UnityFramework          … CPPExceptionTerminate() + 496 (BSG_KSCrashSentry_CPPException.mm:192)
8   libc++abi.dylib         … std::__terminate(void (*)()) + 20 (cxa_handlers.cpp:59)
9   libc++abi.dylib         … std::terminate() + 64 (cxa_handlers.cpp:88)
10  libdispatch.dylib       … _dispatch_client_callout + 40 (object.m:563)

As you’ve noted already, frame 7 CPPExceptionTerminate is central to this. I’m not familiar with the third-party tool this comes from but, just based on that name and the source file, BSG_KSCrashSentry_CPPException.mm, it seems like that this is their custom crash reporter. My best guess here is that:

  • In frame 10, Dispatch has called a block on the main queue.

  • Something in that block has thrown an unhandled language exception.

  • This has been caught by the third-party crash reporter.

What you’d like to know is the backtrace of the code that threw that exception. Normally that shows up in the Last Exception Backtrace section of the crash report, but that’s not present here. It’s likely that the third-party crash reporter is preventing that, either deliberately or accidentally [1].

My advice:

  • If you can disable your third-party crash reporter, do so. I expect that’ll give you more actionable crash reports.

  • If not, talk to your tool vendor to see if they have any advice on how to debug your issue.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] This is a common problem. See my Implementing Your Own Crash Reporter post for a lot more background on this issue.

Hi Eskimo,

Thanks for helping with this.

This crash randomly happens in my device, if I force close the app when game is on loading screen. As per my reproduction steps I can confirm this crash is not user facing. It is happening while app is terminating. Still we want to fix it, since we want to bring down our overall crash rates in App Store. Now, I disabled Bugsnag which is our third party crash reporter and reproduced the crash. Even in the latest crash report which does not have BSG_KSCrashSentry_CPPException.mm in it, I can't find Last Exception Backtrace. Can you please check the attached full crash report and let me know if we can find the root cause?

Thanks, Eshwar

Even in the latest crash report … I can't find Last Exception Backtrace.

Yeah, I think you’re hitting an annoying limitation of our crash reporting system. Based on the other backtraces in your crash report, it’s likely that crash is being caused by a C++ language exception and those don’t record the backtrace. See this thread for the full backstory.

On the plus side, you can reproduce this reasonably easily, which gives you more options than other folks. Are you able to reproduce it with the Xcode debugger attached?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi Eskimo,

I was able to debug the issue by attaching Xcode debugger which helped me to locate the unhandled exception that was happening in app backgrounding flow. Fixing that exception helped to fix the crash as well. Thanks for your help.

Thanks, Eshwar

CPPExceptionTerminate crash in iOS
 
 
Q