Crashed: com.apple.CFNetwork.Connection

I'm facing trouble to find out the cause of crash that happens in ios11.1 of my app.

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

Following is the stack trace provided by Fabric (Crashlytics).



#3. Crashed: com.apple.CFNetwork.Connection

0 libsystem_kernel.dylib 0x184ca1348 __pthread_kill + 8

1 libsystem_pthread.dylib 0x184db5344 pthread_kill$VARIANT$mp + 396

2 libsystem_c.dylib 0x184c10fb8 abort + 140

3 libsystem_c.dylib 0x184be4a9c basename_r + 314

4 CFNetwork 0x18589d460 invocation function for block in TCPIOConnection::_tlsProcessValidateServerCertificates(nw_tls_context*) + 670

5 CFNetwork 0x18589b884 TCPIOConnection::_handleTLSEvent(nw_tls_context*, tls_handshake_message_t, void () block_pointer, bool) + 700

6 libnetwork.dylib 0x186076964 __tcp_connection_set_tls_message_handler_on_nw_connection_block_invoke + 168

7 libboringssl.dylib 0x185f4eb4c __boringssl_context_handshake_message_handler_block_invoke + 160

8 libdispatch.dylib 0x184b0d088 _dispatch_call_block_and_release + 24

9 libdispatch.dylib 0x184b0d048 _dispatch_client_callout + 16

10 libdispatch.dylib 0x184b16e48 _dispatch_queue_serial_drain$VARIANT$mp + 528

11 libdispatch.dylib 0x184b177d8 _dispatch_queue_invoke$VARIANT$mp + 340

12 libdispatch.dylib 0x184b16d00 _dispatch_queue_serial_drain$VARIANT$mp + 200

13 libdispatch.dylib 0x184b177d8 _dispatch_queue_invoke$VARIANT$mp + 340

14 libdispatch.dylib 0x184b18200 _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 400

15 libdispatch.dylib 0x184b204a0 _dispatch_workloop_worker_thread$VARIANT$mp + 644

16 libsystem_pthread.dylib 0x184db2fd0 _pthread_wqthread + 932

17 libsystem_pthread.dylib 0x184db2c20 start_wqthread + 4



--



#0. com.apple.main-thread

0 libsystem_kernel.dylib 0x184c80bc4 mach_msg_trap + 8

1 libsystem_kernel.dylib 0x184c80a3c mach_msg + 72

2 CoreFoundation 0x185131c74 __CFRunLoopServiceMachPort + 196

3 CoreFoundation 0x18512f840 __CFRunLoopRun + 1424

4 CoreFoundation 0x18504ffb8 CFRunLoopRunSpecific + 436

5 GraphicsServices 0x186ee7f84 GSEventRunModal + 100

6 UIKit 0x18e6242f4 UIApplicationMain + 208

...

8 libdyld.dylib 0x184b7256c start + 4



#1. Thread

0 libsystem_kernel.dylib 0x184ca1dbc __workq_kernreturn + 8

1 libsystem_pthread.dylib 0x184db3134 _pthread_wqthread + 1288

2 libsystem_pthread.dylib 0x184db2c20 start_wqthread + 4



#2. Thread

0 libsystem_kernel.dylib 0x184ca1dbc __workq_kernreturn + 8

1 libsystem_pthread.dylib 0x184db2fa0 _pthread_wqthread + 884

2 libsystem_pthread.dylib 0x184db2c20 start_wqthread + 4



#3. Crashed: com.apple.CFNetwork.Connection

0 libsystem_kernel.dylib 0x184ca1348 __pthread_kill + 8

1 libsystem_pthread.dylib 0x184db5344 pthread_kill$VARIANT$mp + 396

2 libsystem_c.dylib 0x184c10fb8 abort + 140

3 libsystem_c.dylib 0x184be4a9c basename_r + 314

4 CFNetwork 0x18589d460 invocation function for block in TCPIOConnection::_tlsProcessValidateServerCertificates(nw_tls_context*) + 670

5 CFNetwork 0x18589b884 TCPIOConnection::_handleTLSEvent(nw_tls_context*, tls_handshake_message_t, void () block_pointer, bool) + 700

6 libnetwork.dylib 0x186076964 __tcp_connection_set_tls_message_handler_on_nw_connection_block_invoke + 168

7 libboringssl.dylib 0x185f4eb4c __boringssl_context_handshake_message_handler_block_invoke + 160

8 libdispatch.dylib 0x184b0d088 _dispatch_call_block_and_release + 24

9 libdispatch.dylib 0x184b0d048 _dispatch_client_callout + 16

10 libdispatch.dylib 0x184b16e48 _dispatch_queue_serial_drain$VARIANT$mp + 528

11 libdispatch.dylib 0x184b177d8 _dispatch_queue_invoke$VARIANT$mp + 340

12 libdispatch.dylib 0x184b16d00 _dispatch_queue_serial_drain$VARIANT$mp + 200

13 libdispatch.dylib 0x184b177d8 _dispatch_queue_invoke$VARIANT$mp + 340

14 libdispatch.dylib 0x184b18200 _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 400

15 libdispatch.dylib 0x184b204a0 _dispatch_workloop_worker_thread$VARIANT$mp + 644

16 libsystem_pthread.dylib 0x184db2fd0 _pthread_wqthread + 932

17 libsystem_pthread.dylib 0x184db2c20 start_wqthread + 4



#4. Thread

0 libsystem_kernel.dylib 0x184ca1dbc __workq_kernreturn + 8

1 libsystem_pthread.dylib 0x184db2fa0 _pthread_wqthread + 884

2 libsystem_pthread.dylib 0x184db2c20 start_wqthread + 4



#5. com.apple.NSURLSession-work

0 libsystem_kernel.dylib 0x184ca01a4 __bsdthread_ctl + 8

1 libsystem_pthread.dylib 0x184dbefb8 _pthread_set_properties_self + 64

2 libdispatch.dylib 0x184b13818 _dispatch_set_priority_and_mach_voucher_slow$VARIANT$mp + 160

3 libdispatch.dylib 0x184b139c8 _dispatch_set_priority_and_voucher_slow$VARIANT$mp + 232

4 libdispatch.dylib 0x184b16f50 _dispatch_queue_serial_drain$VARIANT$mp + 792

5 libdispatch.dylib 0x184b177d8 _dispatch_queue_invoke$VARIANT$mp + 340

6 libdispatch.dylib 0x184b18200 _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 400

7 libdispatch.dylib 0x184b204a0 _dispatch_workloop_worker_thread$VARIANT$mp + 644

8 libsystem_pthread.dylib 0x184db2fd0 _pthread_wqthread + 932

9 libsystem_pthread.dylib 0x184db2c20 start_wqthread + 4



#6. com.apple.uikit.eventfetch-thread

0 libsystem_kernel.dylib 0x184c80bc4 mach_msg_trap + 8

1 libsystem_kernel.dylib 0x184c80a3c mach_msg + 72

2 CoreFoundation 0x185131c74 __CFRunLoopServiceMachPort + 196

3 CoreFoundation 0x18512f840 __CFRunLoopRun + 1424

4 CoreFoundation 0x18504ffb8 CFRunLoopRunSpecific + 436

5 Foundation 0x185a796e4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 304

6 Foundation 0x185a98afc -[NSRunLoop(NSRunLoop) runUntilDate:] + 96

7 UIKit 0x18f1832f4 -[UIEventFetcher threadMain] + 136

8 Foundation 0x185b7a860 __NSThread__start__ + 996

9 libsystem_pthread.dylib 0x184db431c _pthread_body + 308

10 libsystem_pthread.dylib 0x184db41e8 _pthread_body + 310

11 libsystem_pthread.dylib 0x184db2c28 thread_start + 4



#7. com.apple.root.default-qos

0 libsystem_kernel.dylib 0x184ca1648 __semwait_signal + 8

1 libsystem_c.dylib 0x184bbaf70 nanosleep + 212

2 libsystem_c.dylib 0x184c23f30 sleep + 44

3 Disco 0x100c957c8 mosquitto_loop_forever (mosquitto.c:1059)

4 Disco 0x100d15654 partial apply for Analytics.(connect() -> Bool).(closure #1) (Disco.swift:1259)

5 libdispatch.dylib 0x184b0d088 _dispatch_call_block_and_release + 24

6 libdispatch.dylib 0x184b0d048 _dispatch_client_callout + 16

7 libdispatch.dylib 0x184b14090 _dispatch_queue_override_invoke$VARIANT$mp + 716

8 libdispatch.dylib 0x184b1a1c8 _dispatch_root_queue_drain + 596

9 libdispatch.dylib 0x184b19f10 _dispatch_worker_thread3 + 120

10 libsystem_pthread.dylib 0x184db3120 _pthread_wqthread + 1268

11 libsystem_pthread.dylib 0x184db2c20 start_wqthread + 4



#8. com.twitter.crashlytics.ios.MachExceptionServer

0 libsystem_kernel.dylib 0x184c80bc4 mach_msg_trap + 8

1 libsystem_kernel.dylib 0x184c80a3c mach_msg + 72

2 MyAPP... 0x10074a7a8 CLSMachExceptionServer + 4317718440

3 libsystem_pthread.dylib 0x184db431c _pthread_body + 308

4 libsystem_pthread.dylib 0x184db41e8 _pthread_body + 310

5 libsystem_pthread.dylib 0x184db2c28 thread_start + 4



#9. Thread

0 libsystem_kernel.dylib 0x184ca1dbc __workq_kernreturn + 8

1 libsystem_pthread.dylib 0x184db2fa0 _pthread_wqthread + 884

2 libsystem_pthread.dylib 0x184db2c20 start_wqthread + 4



#10. com.apple.NSURLConnectionLoader

0 libsystem_kernel.dylib 0x184c80bc4 mach_msg_trap + 8

1 libsystem_kernel.dylib 0x184c80a3c mach_msg + 72

2 CoreFoundation 0x185131c74 __CFRunLoopServiceMachPort + 196

3 CoreFoundation 0x18512f840 __CFRunLoopRun + 1424

4 CoreFoundation 0x18504ffb8 CFRunLoopRunSpecific + 436

5 CFNetwork 0x1857ba264 +[NSURLConnection(Loader) _resourceLoadLoop:] + 404

6 Foundation 0x185b7a860 __NSThread__start__ + 996

7 libsystem_pthread.dylib 0x184db431c _pthread_body + 308

8 libsystem_pthread.dylib 0x184db41e8 _pthread_body + 310

9 libsystem_pthread.dylib 0x184db2c28 thread_start + 4

Same problem here, many crashes with identical stack trace in a live app. And we are unable to reproduce the crash.

Same problem too, only crashed on iOS 12.x:

Thread 35 Crashed:
0   libsystem_kernel.dylib          __pthread_kill + 8
1   libsystem_pthread.dylib         pthread_kill$VARIANT$mp + 380
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*) + 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$mp + 224
10  ......
11  libdispatch.dylib               _dispatch_call_block_and_release + 24
12  libdispatch.dylib               _dispatch_client_callout + 16
13  libdispatch.dylib               _dispatch_lane_serial_drain$VARIANT$mp + 592
14  libdispatch.dylib               _dispatch_lane_invoke$VARIANT$mp + 480
15  libdispatch.dylib               _dispatch_workloop_invoke$VARIANT$mp + 1960
16  libdispatch.dylib               _dispatch_workloop_worker_thread + 596
17  libsystem_pthread.dylib         _pthread_wqthread + 304
Crashed: com.apple.CFNetwork.Connection
 
 
Q