iOS System Network Library Crash

We are an SDK manufacturer, providing our clients with an HTTP network proxy SDK.

Recently on iOS 17.1.1 version, a problem was encountered. After the proxy is started, the system is prone to crash, which looks like a crash in the iOS network library. The crash information is as follows:

In other versions of iOS (15, 16) etc., I would like to ask whether the cause of the crash can be seen from the information provided? Is it an issue on our side, or a BUG in the iOS system?

How does your SDK work? Does it implement a HTTP proxy? Or is it using an NSURLProtocol subclass? Or something else?

Share and Enjoy

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

How does your SDK work? Does it implement a HTTP proxy? Or is it using an NSURLProtocol subclass? Or something else?

This SDK listens to 2 ports and implements an HTTP/HTTPS proxy locally.

Then, NSURLSession is asked to proxy requests through by setting the proxy configuration of NSURLSessionConfiguration.

Currently, we are not using NSURLProtocol.

This issue, specifically, tends to occur after the first launch of an installed APP.

Crash occur in different places, but this code is often seen.

Currently, we are not using NSURLProtocol.

Cool.

Please post a full Apple crash report, per the instructions in Posting a Crash Report. If you catch this in the debugger, you can generate a crash report by detaching the debugger; to do that, choose Debug > Detach.

Share and Enjoy

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

This Crash can be reproduced in the debug status of XCode.

However, it seems that relevant information cannot be obtained through Analytics in this way.

So, I tried to reproduce it by installing Archive, but a new problem came up during the installation:

Error installing  '/Users/xxxx/Desktop/temp/MAHDemo 2023-12-04 10-42-16/MAHDemo.ipa', ERROR: Error Domain=com.apple.dt.CoreDeviceError Code=3002 "Failed to install the app on the device." UserInfo={NSURL=file:///Users/xxxxxxx/Desktop/temp/MAHDemo%202023-12-04%2010-42-16/MAHDemo.ipa, NSUnderlyingError=0x60002205f810 {Error Domain=com.apple.dt.CoreDeviceError Code=3000 "The item at MAHDemo.ipa is not a valid bundle." UserInfo={NSURL=file:///Users/xxxxxxx/Desktop/temp/MAHDemo%202023-12-04%2010-42-16/MAHDemo.ipa, NSLocalizedFailureReason=Failed to read the bundle., NSLocalizedDescription=The item at MAHDemo.ipa is not a valid bundle.}}, NSLocalizedDescription=Failed to install the app on the device.}
Domain: com.apple.dt.DVTCoreDevice
Code: -1
User Info: {
​    DVTErrorCreationDateKey = "2023-12-04 02:45:13 +0000";
}

System Information

macOS Version 13.6.1 (Build 22G313)
Xcode 15.0.1 (22266) (Build 15A507)
Timestamp: 2023-12-04T10:45:13+08:00 

The same IPA installed on iOS 15, 16 system will not appear.

However, it seems that relevant information cannot be obtained through Analytics in this way.

Yeah it can. If your app is crashed in the debugger, choose Product > Detach and the debugger will detach allowing the crash reporter to ‘see’ the crash.

Share and Enjoy

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

I have obtained 3 crash reports, hopefully they will be of some help.

Those three crash reports are quite different. In the first one, the crash is coming out of NSURL:

0   libxpc.dylib          … _xpc_serializer_pack.cold.2 + 100
1   libxpc.dylib          … _xpc_serializer_pack + 987
2   libxpc.dylib          … _xpc_pipe_pack_message + 167
3   libxpc.dylib          … _xpc_pipe_simpleroutine + 119
4   libsystem_trace.dylib … ___os_activity_stream_reflect_block_invoke + 39
5   libdispatch.dylib     … _dispatch_client_callout + 20
6   libdispatch.dylib     … _dispatch_block_invoke_direct + 300
7   libdispatch.dylib     … dispatch_block_perform + 112
8   libsystem_trace.dylib … _os_activity_stream_reflect + 575
9   libsystem_trace.dylib … _os_log_impl_stream + 503
10  libsystem_trace.dylib … _os_log_impl_flatten_and_send + 7571
11  libsystem_trace.dylib … _os_log + 151
12  libsystem_trace.dylib … _os_log_impl + 23
13  CoreServicesInternal  … pathURLPropertyProviderSetValues(__CFURL const*, __FileCache*, __CFString const* co…
14  CoreServicesInternal  … _FSURLSetResourcePropertyForKey + 207
15  CoreFoundation        … CFURLSetResourcePropertyForKey + 119
16  CoreFoundation        … -[NSURL setResourceValue:forKey:error:] + 103

In the second it’s NSString:

0   libobjc.A.dylib … objc_opt_respondsToSelector + 52
1   Foundation      … _NSDescriptionWithStringProxyFunc + 55
2   CoreFoundation  … __CFStringAppendFormatCore + 8559
3   CoreFoundation  … _CFStringCreateWithFormatAndArgumentsReturningMetadata + 183
4   CoreFoundation  … _CFStringCreateWithFormatAndArgumentsAux2 + 43
5   Foundation      … +[NSString stringWithFormat:] + 67

And only the third has anything to do with networking:

0   libxpc.dylib          … _xpc_serializer_pack.cold.2 + 100
1   libxpc.dylib          … _xpc_serializer_pack + 987
2   libxpc.dylib          … _xpc_pipe_pack_message + 167
3   libxpc.dylib          … _xpc_pipe_simpleroutine + 119
4   libsystem_trace.dylib … ___os_activity_stream_reflect_block_invoke + 39
5   libdispatch.dylib     … _dispatch_client_callout + 20
6   libdispatch.dylib     … _dispatch_block_invoke_direct + 300
7   libdispatch.dylib     … dispatch_block_perform + 112
8   libsystem_trace.dylib … _os_activity_stream_reflect + 575
9   libsystem_trace.dylib … _os_log_impl_stream + 503
10  libsystem_trace.dylib … _os_log_impl_flatten_and_send + 7571
11  libsystem_trace.dylib … _os_log + 151
12  libsystem_trace.dylib … _os_log_impl + 23
13  Network               … nw_connection_add_client_event_internal + 595
14  CFNetwork             … 0x19f661bd5 + 3579

This suggests that you have a general problem that’s affecting a wide range of systems. In my experience such problems are usually related to memory management, and I encourage you to stress test your app with the standard memory debugging tools.

Share and Enjoy

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

iOS System Network Library Crash
 
 
Q