Recently we have got serveral crash report from Organizer. The crash is about cancelTunnelWithError API usage in network extension.
Last Exception Backtrace:
0 CoreFoundation 0x1d879140c __exceptionPreprocess + 160 (NSException.m:202)
1 libobjc.A.dylib 0x1d1a71c10 objc_exception_throw + 56 (objc-exception.mm:356)
2 Foundation 0x1d2b29448 -[NSXPCEncoder _checkObject:] + 288 (NSXPCCoder.m:0)
3 Foundation 0x1d2b29114 -[NSXPCEncoder _encodeUnkeyedObject:] + 36 (NSXPCCoder.m:396)
4 Foundation 0x1d2b28ddc -[NSXPCEncoder _encodeArrayOfObjects:forKey:] + 180 (NSXPCCoder.m:523)
5 Foundation 0x1d2b2ba24 -[NSDictionary(NSDictionary) encodeWithCoder:] + 568 (NSDictionary_Foundation.m:47)
6 Foundation 0x1d2b28ff8 -[NSXPCEncoder _encodeObject:] + 436 (NSXPCCoder.m:373)
7 Foundation 0x1d2b28ddc -[NSXPCEncoder _encodeArrayOfObjects:forKey:] + 180 (NSXPCCoder.m:523)
8 Foundation 0x1d2b2ba24 -[NSDictionary(NSDictionary) encodeWithCoder:] + 568 (NSDictionary_Foundation.m:47)
9 Foundation 0x1d2b28ff8 -[NSXPCEncoder _encodeObject:] + 436 (NSXPCCoder.m:373)
10 Foundation 0x1d2b28ddc -[NSXPCEncoder _encodeArrayOfObjects:forKey:] + 180 (NSXPCCoder.m:523)
11 Foundation 0x1d2b2ba24 -[NSDictionary(NSDictionary) encodeWithCoder:] + 568 (NSDictionary_Foundation.m:47)
12 Foundation 0x1d2b28ff8 -[NSXPCEncoder _encodeObject:] + 436 (NSXPCCoder.m:373)
13 Foundation 0x1d2b54378 _NSXPCSerializationAddInvocationWithOnlyObjectArgumentsArray + 112 (NSXPCCoder_InvocationSerialization.m:36)
14 Foundation 0x1d2b49c2c -[NSXPCEncoder _encodeInvocationObjectArgumentsOnly:count:typeString:selector:isReply:into:] + 208 (NSXPCCoder.m:498)
15 Foundation 0x1d2b472dc _sendReplyArgumentsOnly + 172 (NSXPCConnection.m:359)
16 Foundation 0x1d30649f8 __64-[NSXPCConnection _decodeAndInvokeMessageWithEvent:reply:flags:]_block_invoke_4 + 92 (NSXPCConnection.m:573)
17 Foundation 0x1d2baef90 -[_NSXPCConnectionRequestedReplies endTransactionForSequence:completionHandler:] + 192 (NSXPCConnectionHelpers.m:516)
18 Foundation 0x1d3064974 __64-[NSXPCConnection _decodeAndInvokeMessageWithEvent:reply:flags:]_block_invoke_3 + 148 (NSXPCConnection.m:569)
19 NetworkExtension 0x1ee499f6c -[NEExtensionProviderContext cancelWithError:] + 196 (NEExtensionProviderContext.m:247)
20 NetworkExtension 0x1ee49ccb8 -[NEExtensionTunnelProviderContext cancelWithError:] + 68 (NEExtensionTunnelProviderContext.m:185)
21 NetworkExtension 0x1ee578bdc -[NEPacketTunnelProvider cancelTunnelWithError:] + 164 (NEPacketTunnelProvider.m:84)
22 *****PacketTunnelProvider 0x100659318 *****PacketTunnelProvider.cancelTunnelWithError(_:) + 360 (*****PacketTunnelProvider.swift:162)
23 *****PacketTunnelProvider 0x100659370 @objc *****PacketTunnelProvider.cancelTunnelWithError(_:) + 56 (<compiler-generated>:0)
24 ***** 0x100778c70 *****PacketTunnelProviderImpl.cancelTunnelWithError(_:cancelingFunction:) + 720 (******PacketTunnelProviderImpl.swift)
25 ***** 0x10077e434 closure #1 in *****PacketTunnelProviderImpl.******
26 MCKit 0x1007b9934 partial apply for closure #1 in *****PacketTunnelProviderImpl.****(****) + 32 (<compiler-generated>:0)
27 MCKit 0x100774e9c thunk for @escaping @callee_guaranteed @Sendable (@guaranteed Data?, @guaranteed NSURLResponse?, @guaranteed Error?) -> () + 148 (<compiler-generated>:0)
28 CFNetwork 0x1d9774e60 __40-[__NSURLSessionLocal taskForClassInfo:]_block_invoke + 476 (LocalSession.mm:718)
29 CFNetwork 0x1d9783da8 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke_2 + 156 (LocalSessionTask.mm:544)
30 libdispatch.dylib 0x1df5347a8 _dispatch_call_block_and_release + 24 (init.c:1518)
31 libdispatch.dylib 0x1df535780 _dispatch_client_callout + 16 (object.m:560)
32 libdispatch.dylib 0x1df5106fc _dispatch_lane_serial_drain$VARIANT$armv81 + 600 (queue.c:3885)
33 libdispatch.dylib 0x1df5111e4 _dispatch_lane_invoke$VARIANT$armv81 + 432 (queue.c:3976)
34 libdispatch.dylib 0x1df51af14 _dispatch_workloop_worker_thread + 608 (queue.c:6507)
35 libsystem_pthread.dylib 0x2227ddbd0 _pthread_wqthread + 284 (pthread.c:2618)
36 libsystem_pthread.dylib 0x2227dd720 start_wqthread + 8
So we have some self defined error enums which conforms CustomNSError protocol. Not sure if there is something wrong from Error in swift to NSError in objective-c.
This issue is not existed for old iOS version before. And the same code works fine on macOS.