invocation function for block in TCPIOConnection::_tlsValidateServerTrust

Hello, my app crashed on iOS 12.x, it only crashed on iOS 12.x system, I don’t know what to do? I use NSURLSession to download remote image. Please help me thanks

I have tried to look out and explore but can't find the reason or nor reproduce it yet.

Date/Time:       2021-08-10 04:28:44.855 +0800
OS Version:      iOS 12.4 (16G77)
Report Version:  104

Monitor Type:    Unix Signal
Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000 at 0x0000000190b530dc
Crashed Thread:  40

Pthread id: 1160889
Thread 0:
0   libsystem_kernel.dylib          mach_msg_trap + 8
1   libsystem_kernel.dylib          mach_msg + 72
2   CoreFoundation                  __CFRunLoopServiceMachPort + 236
3   CoreFoundation                  __CFRunLoopRun + 1360
4   CoreFoundation                  CFRunLoopRunSpecific + 436
5   GraphicsServices                GSEventRunModal + 104
6   UIKitCore                       UIApplicationMain + 212
7   MyAPP                         main + 300
8   libdyld.dylib                   start + 4

Pthread id: 1166811
Thread 40 Crashed:
0   libsystem_kernel.dylib          __pthread_kill + 8
1   libsystem_pthread.dylib         pthread_kill$VARIANT$armv81 + 296
2   libsystem_c.dylib               abort + 140
3   libsystem_c.dylib               __assert_rtn + 312
4   CFNetwork                       invocation function for block in TCPIOConnection::_tlsValidateServerTrust(nw_tls_context*) + 0
5   CFNetwork                       TCPIOConnection::_handleConnectionEvent(unsigned int, void const*) + 980
6   CFNetwork                       invocation function for block in TCPIOConnection::_startConnection() + 108
7   libnetwork.dylib                __tcp_connection_start_block_invoke + 1020
8   libdispatch.dylib               _dispatch_client_callout + 16
9   libdispatch.dylib               _dispatch_block_invoke_direct$VARIANT$armv81 + 216
10  MyAPP                         __innerBlockOnce_block_invoke + 148
11  libdispatch.dylib               _dispatch_call_block_and_release + 24
12  libdispatch.dylib               _dispatch_client_callout + 16
13  libdispatch.dylib               _dispatch_lane_serial_drain$VARIANT$armv81 + 548
14  libdispatch.dylib               _dispatch_lane_invoke$VARIANT$armv81 + 464
15  libdispatch.dylib               _dispatch_workloop_invoke$VARIANT$armv81 + 1900
16  libdispatch.dylib               _dispatch_workloop_worker_thread + 584
17  libsystem_pthread.dylib         _pthread_wqthread + 304
Enqueue thread backtrace:
0   MyAPP                         innerBlockOnce + 36
1   MyAPP                         _dispatch_async + 44
2   libnetwork.dylib                nw_connection_report_state_with_handler_locked + 1196
3   libnetwork.dylib                nw_connection_endpoint_report + 7392
4   libnetwork.dylib                nw_endpoint_handler_report + 180
5   libnetwork.dylib                nw_endpoint_resolver_update + 8220
6   libnetwork.dylib                __nw_resolver_update_client_block_invoke + 104
7   MyAPP                         __innerBlockOnce_block_invoke + 148
8   libdispatch.dylib               _dispatch_call_block_and_release + 24
9   libdispatch.dylib               _dispatch_client_callout + 16
10  libdispatch.dylib               _dispatch_workloop_invoke$VARIANT$armv81 + 2200
11  libdispatch.dylib               _dispatch_workloop_worker_thread + 584
12  libsystem_pthread.dylib         _pthread_wqthread + 304
13  libsystem_pthread.dylib         start_wqthread + 4
Enqueue thread backtrace:
0   MyAPP                         innerBlockOnce + 36
1   MyAPP                         _dispatch_async + 44
2   libnetwork.dylib                nw_queue_context_async + 88
3   libnetwork.dylib                nw_resolver_update_client + 316
4   libnetwork.dylib                nw_resolver_update_status_locked + 632
5   libnetwork.dylib                nw_resolver_host_resolve_callback + 2472
6   libsystem_dnssd.dylib           handle_addrinfo_response + 412
7   libsystem_dnssd.dylib           DNSServiceProcessResult + 596
8   MyAPP                         __innerBlock_block_invoke + 140
9   libdispatch.dylib               _dispatch_client_callout + 16
10  libdispatch.dylib               _dispatch_continuation_pop$VARIANT$armv81 + 404
11  libdispatch.dylib               _dispatch_source_invoke$VARIANT$armv81 + 1232
12  libdispatch.dylib               _dispatch_workloop_invoke$VARIANT$armv81 + 1900
13  libdispatch.dylib               _dispatch_workloop_worker_thread + 584
14  libsystem_pthread.dylib         _pthread_wqthread + 304
15  libsystem_pthread.dylib         start_wqthread + 4
Enqueue thread backtrace:
0   MyAPP                         innerBlock + 36
1   MyAPP                         _dispatch_source_set_event_handler + 44
2   libsystem_dnssd.dylib           DNSServiceSetDispatchQueue + 236
3   libnetwork.dylib                nw_resolver_create_dns_service_locked + 1836
4   libnetwork.dylib                __nw_resolver_set_update_handler_block_invoke + 96
5   libnetwork.dylib                nw_queue_context_async_if_needed + 100
6   libnetwork.dylib                nw_resolver_set_update_handler + 328
7   libnetwork.dylib                -[NWConcrete_nw_endpoint_resolver startWithHandler:] + 1696
8   libnetwork.dylib                nw_endpoint_handler_path_change + 11544
9   libnetwork.dylib                __nw_endpoint_handler_initialize_association_block_invoke + 172
10  libnetwork.dylib                __nw_association_update_paths_block_invoke.73 + 64
11  libnetwork.dylib                nw_hash_table_apply + 316
12  libnetwork.dylib                nw_association_update_paths + 320
13  libnetwork.dylib                nw_path_necp_update_evaluator + 1224
14  libnetwork.dylib                nw_path_necp_check_for_updates + 908
15  libdispatch.dylib               _dispatch_client_callout + 16
16  libdispatch.dylib               _dispatch_continuation_pop$VARIANT$armv81 + 404
17  libdispatch.dylib               _dispatch_source_invoke$VARIANT$armv81 + 1232
18  libdispatch.dylib               _dispatch_workloop_invoke$VARIANT$armv81 + 1900
19  libdispatch.dylib               _dispatch_workloop_worker_thread + 584
20  libsystem_pthread.dylib         _pthread_wqthread + 304
21  libsystem_pthread.dylib         start_wqthread + 4
Answered by DTS Engineer in 692250022

Using the Apple crash report I was able to track down the assertion that’s causing this crash. Unfortunately that doesn’t help you very much. The assertion is related to internal state within the TCPIOConnection subsystem.

For context, TCPIOConnection is the way that older versions of CFNetwork interact with TCP connection. This code has changed a lot in recent releases, with the roll out of Network framework, which probably explains why you’re not seeing it on iOS 13 and later.

I don’t think there’s much you can do about this. If you’re seeing this crash a lot, your best option would be to drop iOS 12 support. This isn’t that unusual; most iOS apps don’t support that far back. OTOH, if you’re seeing this infrequently then you may just want to live with it )-:

Share and Enjoy

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

invocation function for block in TCPIOConnection::_tlsValidateServerTrust

Please post a full Apple crash report. For specific advice on how to do that, see Posting a Crash Report.

Share and Enjoy

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

This is not an Apple crash report, alas, and so there’s not much I can do with it.

Consider the backtrace of the crashing thread:

Pthread id: 1408149
Thread 5 Crashed:
0   libsystem_kernel.dylib  __pthread_kill + 8
1   libsystem_pthread.dylib pthread_kill$VARIANT$armv81 + 296
2   libsystem_c.dylib       abort + 140
3   libsystem_c.dylib       basename_r + 0
4   CFNetwork               invocation function for block in 
                            TCPIOConnection::_tlsValidateServerTrust
                            (nw_tls_context*) + 0
5   CFNetwork               TCPIOConnection::_handleConnectionEvent
                            (unsigned int, void const*) + 1024

Note how the function offset of frame 4 is 0. That’s very unlikely to be accurate, and this offset is critical to understanding the root cause of this issue.

My advice is that you disable your third-party crash reporter and see if you can gather an Apple crash repor for the problem.

Share and Enjoy

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

What are the possibilities of this problem?

No idea, sorry. As a said earlier, I can’t do much without an Apple crash report.

Share and Enjoy

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

Hello, I sent another email, I don’t know if this crash report meets the requirements.

Accepted Answer

Using the Apple crash report I was able to track down the assertion that’s causing this crash. Unfortunately that doesn’t help you very much. The assertion is related to internal state within the TCPIOConnection subsystem.

For context, TCPIOConnection is the way that older versions of CFNetwork interact with TCP connection. This code has changed a lot in recent releases, with the roll out of Network framework, which probably explains why you’re not seeing it on iOS 13 and later.

I don’t think there’s much you can do about this. If you’re seeing this crash a lot, your best option would be to drop iOS 12 support. This isn’t that unusual; most iOS apps don’t support that far back. OTOH, if you’re seeing this infrequently then you may just want to live with it )-:

Share and Enjoy

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

invocation function for block in TCPIOConnection::_tlsValidateServerTrust
 
 
Q