Crash __CFRunLoopServiceMachPort - 99% background

Hello there,

we have the following crash in production (99% in background) with our latest release, but we are not able to indentify 100% the main actor. It could be Intercom SDK.

Firebase reports:

Crash CoreFoundation __CFRunLoopServiceMachPort mach_msg

# Crashlytics - Stack trace
# Application: 
# Platform: apple
# Version: 
# Issue: b2e30d6f3d1736d78cee0f6c17eefdcd
# Session: 686a67d122ff47ab8fd89b58cef2e38b_DNE_0_v2
# Date: Tue Jul 02 2024 07:26:48 GMT+0200 (Central European Summer Time)

Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  GraphicsServices               0x11a8 GSEventRunModal + 164
8  UIKitCore                      0x40a90c -[UIApplication _run] + 888
9  UIKitCore                      0x4be9d0 UIApplicationMain + 340
10 UIKitCore                      0x638384 keypath_get_selector_hoverStyle + 11024
11 MYAPP                       0x6a348 main + 4365591368 (YAppDelegate.swift:4365591368)
12 ???                            0x1abc85e4c (Missing)

com.apple.CoreMotion.MotionThread
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  CoreFoundation                 0xc0f04 CFRunLoopRun + 64
8  CoreMotion                     0x10210 (Missing UUID e4a6f107b302327ca121c9bebacca8f4)
9  libsystem_pthread.dylib        0x606c _pthread_start + 136
10 libsystem_pthread.dylib        0x10d8 thread_start + 8

com.apple.uikit.eventfetch-thread
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  Foundation                     0xc7e4c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8  Foundation                     0xc7c9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9  UIKitCore                      0x41e640 -[UIEventFetcher threadMain] + 420
10 Foundation                     0xde718 __NSThread__start__ + 732
11 libsystem_pthread.dylib        0x606c _pthread_start + 136
12 libsystem_pthread.dylib        0x10d8 thread_start + 8

GAIThread
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  Foundation                     0xc7e4c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8  Foundation                     0xc7d20 -[NSRunLoop(NSRunLoop) run] + 64
9  MYAPP                       0xfb42c8 +[GAI threadMain:] + 4381622984
10 Foundation                     0xde718 __NSThread__start__ + 732
11 libsystem_pthread.dylib        0x606c _pthread_start + 136
12 libsystem_pthread.dylib        0x10d8 thread_start + 8

com.google.firebase.crashlytics.MachExceptionServer
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  MYAPP                       0xf77f40 FIRCLSMachExceptionServer + 194 (FIRCLSMachException.c:194)
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  CFNetwork                      0xfdc90 _CFHostIsDomainTopLevel + 108176
8  Foundation                     0xde718 __NSThread__start__ + 732
9  libsystem_pthread.dylib        0x606c _pthread_start + 136
10 libsystem_pthread.dylib        0x10d8 thread_start + 8

Thread
0  libsystem_kernel.dylib         0x73ec __semwait_signal + 8
1  libsystem_c.dylib              0x165f0 nanosleep + 220
2  libsystem_c.dylib              0x7372c sleep + 52
3  Intercom                       0x86db8 IntercomSDK_sentrycrashccd_init + 888
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

SentryCrash Exception Handler (Secondary)
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x2d78 thread_suspend + 112
3  Intercom                       0x93024 IntercomSDK_sentrycrashcm_machexception_getAPI + 1144
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

SentryCrash Exception Handler (Primary)
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  Intercom                       0x93050 IntercomSDK_sentrycrashcm_machexception_getAPI + 1188
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.sentry.app-hang-tracker
0  libsystem_kernel.dylib         0x73ec __semwait_signal + 8
1  libsystem_c.dylib              0x165f0 nanosleep + 220
2  Foundation                     0x21a714 +[NSThread sleepForTimeInterval:] + 160
3  Intercom                       0x75b3c IntercomSDK_PINRemoteImageManagerSubclassOverridesSelector + 51952
4  Foundation                     0xde718 __NSThread__start__ + 732
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

WebThread
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  WebCore                        0x138f2a0  + 780
8  libsystem_pthread.dylib        0x606c _pthread_start + 136
9  libsystem_pthread.dylib        0x10d8 thread_start + 8

Thread
0  libsystem_pthread.dylib        0x10c4 start_wqthread + 8671002818

JavaScriptCore libpas scavenger
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  JavaScriptCore                 0x155b0a4 scavenger_thread_main + 1512
3  libsystem_pthread.dylib        0x606c _pthread_start + 136
4  libsystem_pthread.dylib        0x10d8 thread_start + 8

Thread
0  libsystem_pthread.dylib        0x10c4 start_wqthread + 8671002818

BSXPCCnx:com.apple.backboard.hid-services.xpc
0  libsystem_kernel.dylib         0x1564 kevent_id + 8
1  libdispatch.dylib              0x267d4 _dispatch_kq_poll + 228
2  libdispatch.dylib              0x25d18 _dispatch_event_loop_poke + 340
3  BoardServices                  0x1b194 -[BSXPCServiceConnection _connection_consumeLock_handleError:notYetLocked:] + 844
4  libxpc.dylib                   0x11cbc _xpc_connection_call_event_handler + 144
5  libxpc.dylib                   0x13810 _xpc_connection_mach_event + 1156
6  libdispatch.dylib              0x3e94 _dispatch_client_callout4 + 20
7  libdispatch.dylib              0x239a4 _dispatch_mach_cancel_invoke + 128
8  libdispatch.dylib              0x20f20 _dispatch_mach_invoke + 908
9  libdispatch.dylib              0xb284 _dispatch_lane_serial_drain + 368
10 libdispatch.dylib              0xbf64 _dispatch_lane_invoke + 432
11 libdispatch.dylib              0x16cb4 _dispatch_root_queue_drain_deferred_wlh + 288
12 libdispatch.dylib              0x16528 _dispatch_workloop_worker_thread + 404
13 libsystem_pthread.dylib        0x4934 _pthread_wqthread + 288
14 libsystem_pthread.dylib        0x10cc start_wqthread + 8

Thread
0  libsystem_pthread.dylib        0x10c4 start_wqthread + 8671002818

Thread
0  libsystem_pthread.dylib        0x10c4 start_wqthread + 8671002818

Any suggestion?

Answered by DTS Engineer in 794222022

You won’t be able to debug this based on the info from your third-party crash reporter. In fact, I’m not ever sure there’s anything to debug! The crash report says that it’s crashed here:

Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x1808 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x5008 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x4f20 mach_msg_overwrite + 436
3 libsystem_kernel.dylib 0x4d60 mach_msg + 24
4 CoreFoundation 0x53f5c __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x53600 __CFRunLoopRun + 1208
6 CoreFoundation 0x52cd8 CFRunLoopRunSpecific + 608
7 GraphicsServices 0x11a8 GSEventRunModal + 164
8 UIKitCore 0x40a90c -[UIApplication _run] + 888
9 UIKitCore 0x4be9d0 UIApplicationMain + 340
10 UIKitCore 0x638384 keypath_get_selector_hoverStyle + 11024
11 MYAPP 0x6a348 main + 4365591368 (YAppDelegate.swift:4365591368)
12 ??? 0x1abc85e4c (Missing)

but that makes no sense. This indicates that your main thread crashed, but the main thread is suspended in its run loop waiting for an event to arrive.

IMO you should disable this third-party crash reporter [1] and see if you get an Apple crash report. If so, please post that here, using the process described in Posting a Crash Report.

Share and Enjoy

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

[1] Because third-party crash reporter can, and often do, mess up the Apple crash reporter. See Implementing Your Own Crash Reporter for all the gory details here.

I'm having the same problem here

Did you solve it?

And are you using any Firebase service such as Analytics, Crashlytics etc?

Accepted Answer

You won’t be able to debug this based on the info from your third-party crash reporter. In fact, I’m not ever sure there’s anything to debug! The crash report says that it’s crashed here:

Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x1808 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x5008 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x4f20 mach_msg_overwrite + 436
3 libsystem_kernel.dylib 0x4d60 mach_msg + 24
4 CoreFoundation 0x53f5c __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x53600 __CFRunLoopRun + 1208
6 CoreFoundation 0x52cd8 CFRunLoopRunSpecific + 608
7 GraphicsServices 0x11a8 GSEventRunModal + 164
8 UIKitCore 0x40a90c -[UIApplication _run] + 888
9 UIKitCore 0x4be9d0 UIApplicationMain + 340
10 UIKitCore 0x638384 keypath_get_selector_hoverStyle + 11024
11 MYAPP 0x6a348 main + 4365591368 (YAppDelegate.swift:4365591368)
12 ??? 0x1abc85e4c (Missing)

but that makes no sense. This indicates that your main thread crashed, but the main thread is suspended in its run loop waiting for an event to arrive.

IMO you should disable this third-party crash reporter [1] and see if you get an Apple crash report. If so, please post that here, using the process described in Posting a Crash Report.

Share and Enjoy

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

[1] Because third-party crash reporter can, and often do, mess up the Apple crash reporter. See Implementing Your Own Crash Reporter for all the gory details here.

Thank you @DTS Engineer .

It looks Firebase is the main problem here (a lot of issues opened days ago), @iamgaspar check this https://github.com/firebase/firebase-ios-sdk/releases/tag/10.28.1. I've just found that :)

Crash __CFRunLoopServiceMachPort - 99% background
 
 
Q