Segmentation fault 11 Crash in [WCSession onqueue_sendMessageData:replyHandler:errorHandler:dictionaryMessage:] on watchOS 9.0/9.1

Hello everyone!

Recently my watch app has been receiving a lot of crash reports, all of them from watchOS 9.0 and 9.1. The crash reports suggest SIGNAL 11 Segmentation fault: 11 crash, and the call stack is located in the WatchConnectivity framework -[WCSession onqueue_ sendMessageData:replyHandler:errorHandler:dictionaryMessage:] + 340 (WCSession.m:674). Now it has become the most common crash of my app.

As I understand it, Segmentation fault: 11 suggests some binary or compiler-level problem. Maybe the way I'm calling the API is triggering a problem within the system?

Sample Crash Log:

Incident Identifier: ***
Hardware Model:      Watch6,9
Process:             WatchApp [2338]
Path:                ***
Identifier:          io.qifeng.HiCoffee.watchkitapp
Version:             4.1.1 (7992)
AppStoreTools:       14A305
AppVariant:          1:Watch6,9:8
Code Type:           0200000C (Native)
Role:                unknown
Parent Process:      launchd [1]
Coalition:           io.qifeng.HiCoffee.watchkitapp [450]

Date/Time:           2022-10-11 07:14:55.0777 +0200
OS Version:          Watch OS 9.0 (20R361)
Release Type:        User
Baseband Version:    5.00.00
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000004
Exception Codes: 0x0000000000000001, 0x0000000000000004
VM Region Info: 0x4 is not in any region.  Bytes before following region: 68141052
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                     40fc000-4100000   [   16K] r-x/r-x SM=COW  ....app/WatchApp
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [2338]

Triggered by Thread:  7


Thread 0 name:
Thread 0:
0   WatchApp                      	0x000000000418f1dc @objc ComplicationController2.getComplicationDescriptors(handler:) + 0 (<compiler-generated>:0)
1   libdispatch.dylib             	0x000000002ba6b590 _dispatch_call_block_and_release + 24 (init.c:1518)
2   libdispatch.dylib             	0x000000002ba6cd7c _dispatch_client_callout + 16 (object.m:560)
3   libdispatch.dylib             	0x000000002ba7a114 _dispatch_main_queue_drain + 800 (inline_internal.h:2631)
4   libdispatch.dylib             	0x000000002ba79de4 _dispatch_main_queue_callback_4CF + 40 (queue.c:7804)
...

Thread 1 name:
Thread 1:
0   libsystem_kernel.dylib        	0x000000002c81c18c __ulock_wake + 8
...

Thread 2 name:
Thread 2:
0   libsystem_kernel.dylib        	0x000000002c81b0f8 kevent_qos + 8

...

Thread 6 name:
Thread 6:
0   WatchConnectivity             	0x000000005350996c __31-[WCXPCManager setupConnection]_block_invoke_2 + 0 (WCXPCManager.m:92)
1   libdispatch.dylib             	0x000000002ba6b590 _dispatch_call_block_and_release + 24 (init.c:1518)
2   libdispatch.dylib             	0x000000002ba6cd7c _dispatch_client_callout + 16 (object.m:560)
3   libdispatch.dylib             	0x000000002ba73968 _dispatch_lane_serial_drain + 548 (inline_internal.h:2631)
4   libdispatch.dylib             	0x000000002ba74454 _dispatch_lane_invoke + 388 (queue.c:3939)
5   libdispatch.dylib             	0x000000002ba7e2a4 _dispatch_workloop_worker_thread + 628 (queue.c:6766)
6   libsystem_pthread.dylib       	0x000000006580947c _pthread_wqthread + 280 (pthread.c:2618)
7   libsystem_pthread.dylib       	0x000000006580951c start_wqthread + 8

Thread 7 name:
Thread 7 Crashed: ☠️☠️☠️
0   libdispatch.dylib             	0x000000002ba81fd4 dispatch_source_cancel + 8 (inline_internal.h:231)
1   WatchConnectivity             	0x00000000534f84b4 __81-[WCSession onqueue_sendMessageData:replyHandler:errorHandler:dictionaryMessage:]_block_invoke + 48 (WCSession.m:675)
2   libdispatch.dylib             	0x000000002ba6cd7c _dispatch_client_callout + 16 (object.m:560)
3   libdispatch.dylib             	0x000000002ba6fe7c _dispatch_continuation_pop + 388 (inline_internal.h:2631)
4   libdispatch.dylib             	0x000000002ba81a90 _dispatch_source_invoke + 1760 (source.c:596)
5   libdispatch.dylib             	0x000000002ba7cfe8 _dispatch_root_queue_drain + 332 (inline_internal.h:0)
6   libdispatch.dylib             	0x000000002ba7d7a4 _dispatch_worker_thread2 + 168 (queue.c:6969)
7   libsystem_pthread.dylib       	0x0000000065809440 _pthread_wqthread + 220 (pthread.c:2631)
8   libsystem_pthread.dylib       	0x000000006580951c start_wqthread + 8

Thread 8 name:
Thread 8:
0   libsystem_kernel.dylib        	0x000000002c81e210 kevent + 8
...

Thread 9:
0   WatchApp                      	0x000000000458cd70 monitorCachedData + 756 (KSCrashCachedData.c:0)
...

Thread 10:
0   libsystem_pthread.dylib       	0x0000000065809514 start_wqthread + 0

I am currently unable to reproduce this problem on my own. Do you have any good suggestions for me?

FB11726102

Hi, have you found out what the issue was?

Segmentation fault 11 Crash in [WCSession onqueue_sendMessageData:replyHandler:errorHandler:dictionaryMessage:] on watchOS 9.0/9.1
 
 
Q