XPC API Misuse - iOS 9 crash

We encountered a large number of crashes reported by Crashlytics, but our development team was unable to reproduce it so far. It seems to happen after upgrading to iOS 9 or iOS 9.0.1.


Here is the stacktrace from Crashlytics:


Thread : Crashed: XPC API Misuse: Attempt to send a message expecting a reply to  (com.apple.networking.connection.0x15b636bc0)
0  libxpc.dylib                   0x00000001999e288c _xpc_api_misuse + 52
1  libxpc.dylib                   0x00000001999e288c _xpc_api_misuse + 52
2  libxpc.dylib                   0x00000001999cdb38 _xpc_serializer_create
3  libxpc.dylib                   0x00000001999cda1c xpc_connection_send_message + 80
4  libsystem_network.dylib        0x0000000199930be0 net_helper_send + 256
5  libsystem_network.dylib        0x000000019992bc94 tcp_connection_create_waiting_reply + 84
6  libsystem_network.dylib        0x000000019992ee6c __tcp_connection_allocate_block_invoke + 224
7  libsystem_network.dylib        0x000000019993424c __net_helper_endpoint_deliver_block_invoke_2 + 44
8  libdispatch.dylib              0x00000001997897b0 _dispatch_call_block_and_release + 24
9  libdispatch.dylib              0x0000000199789770 _dispatch_client_callout + 16
10 libdispatch.dylib              0x000000019979575c _dispatch_queue_drain + 864
11 libdispatch.dylib              0x000000019978d274 _dispatch_queue_invoke + 464
12 libdispatch.dylib              0x000000019979762c _dispatch_root_queue_drain + 728
13 libdispatch.dylib              0x000000019979734c _dispatch_worker_thread3 + 112
14 libsystem_pthread.dylib        0x000000019999d478 _pthread_wqthread + 1092


Does anybody know about what could be the cause of this crash? If so, is there a fix/workaround for it?


Thanks,

Peter

Replies

Hey - Fabric developer here. Chiming in because our code appears in that stack trace. Of course, we only have visibility into crashes that have our code in it, so it's always hard to know if we are involved.


I've filed a bug about this one: 28651745. While our use of NSURLSession's background upload facility has increased significantly recently, our pattern of usage hasn't changed. This particular crash also appears to happen exclusively in iOS 10.

Hi Mattie,


If it helps, we just got a similar crash recorded in Fabric with an identical stack trace. From iOS 10.0.2 (iPhone 6; Crashlytics SDK 3.8.1):


Crashed: XPC API Misuse: Over-resume of a connection.
0  libxpc.dylib                   0x185fe26b0 _xpc_api_misuse + 48
1  libxpc.dylib                   0x185fe26b0 _xpc_api_misuse + 48
2  libxpc.dylib                   0x185fcec08 xpc_connection_resume + 76
3  CFNetwork                      0x1875c8500 -[__NSURLBackgroundSession setupXPCConnection] + 292
4  CFNetwork                      0x1875c9260 -[__NSURLBackgroundSession ensureRemoteSession] + 64
5  CFNetwork                      0x187613bb4 -[__NSCFBackgroundSessionTask setTaskDescription:] + 52
6  Curious                        0x1002f4df0 -[ANSUploader startNewUploadRequest:filePath:uniqueName:] + 4298132976
7  Curious                        0x1002f5358 __72-[ANSUploader checkSession:forTasksMatchingDescription:completionBlock:]_block_invoke + 4298134360
8  CFNetwork                      0x1876af978 __46-[NSURLSession getTasksWithCompletionHandler:]_block_invoke_2 + 232
9  CFNetwork                      0x1875d1d58 __67-[__NSURLBackgroundSession _onqueue_getTasksWithCompletionHandler:]_block_invoke + 28
10 Foundation                     0x1879bd7e4 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
11 Foundation                     0x187902358 -[NSBlockOperation main] + 96
12 Foundation                     0x1878f2954 -[__NSOperationInternal _start:] + 620
13 Foundation                     0x1879bfb90 __NSOQSchedule_f + 228
14 libdispatch.dylib              0x185d851c0 _dispatch_client_callout + 16
15 libdispatch.dylib              0x185d93444 _dispatch_queue_serial_drain + 928
16 libdispatch.dylib              0x185d889a8 _dispatch_queue_invoke + 652
17 libdispatch.dylib              0x185d9538c _dispatch_root_queue_drain + 572
18 libdispatch.dylib              0x185d950ec _dispatch_worker_thread3 + 124
19 libsystem_pthread.dylib        0x185f8d2c8 _pthread_wqthread + 1288
20 libsystem_pthread.dylib        0x185f8cdb4 start_wqthread + 4

We also had the crash with iOS 10.


http://stackoverflow.com/questions/39644292/crashed-xpc-api-misuse-over-resume-of-a-connection


Device: iPhone 6+
iOS: 10.0.1


The stack trace is:


    Crashed: XPC API Misuse: Over-resume of a connection.
    0  libxpc.dylib                   0x18eb526b0 _xpc_api_misuse + 48
    1  libxpc.dylib                   0x18eb526b0 _xpc_api_misuse + 48
    2  libxpc.dylib                   0x18eb3ec08 xpc_connection_resume + 76
    3  CFNetwork                      0x190138500 -[__NSURLBackgroundSession setupXPCConnection] + 292
    4  CFNetwork                      0x190139260 -[__NSURLBackgroundSession ensureRemoteSession] + 64
    5  libdispatch.dylib              0x18e8f5200 _dispatch_call_block_and_release + 24
    6  libdispatch.dylib              0x18e8f51c0 _dispatch_client_callout + 16
    7  libdispatch.dylib              0x18e903444 _dispatch_queue_serial_drain + 928
    8  libdispatch.dylib              0x18e8f89a8 _dispatch_queue_invoke + 652
    9  libdispatch.dylib              0x18e903940 _dispatch_queue_override_invoke + 360
    10 libdispatch.dylib              0x18e90538c _dispatch_root_queue_drain + 572
    11 libdispatch.dylib              0x18e9050ec _dispatch_worker_thread3 + 124
    12 libsystem_pthread.dylib        0x18eafd2c8 _pthread_wqthread + 1288
    13 libsystem_pthread.dylib        0x18eafcdb4 start_wqthread + 4

Folks, it would help if you each filed your own bug report about this including, at a minimum, a crash report. Ideally it’d best if you could also include a small test project that reproduces the problem, although I realise that can be tricky when the bug is hard to reproduce.

If you do file a bug report, please post the number here, just for the record.

@mattie, I took a look at your bug report (r. 28651745) and it seems to be waiting input from you.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hey @eskimo !


That radar is indeed waiting for my input. But, the request was to attach Apple-generated reports. As I indicated when originally filing the report, I'm afraid I don't have access to end-users or developers' Apple crashes. I'm attempting to track some down from our customers. If anyone following along has a relevent Apple crash report, it would be greatly appreciated.

Did this get resolved? My app keeps crashing at start, opens only on the third attempt. Crashlytics shows the same stack trace. I cannot replicate this bug! So not sure if reporting this as a bug will help. FYI: this specific crash has happened on iOS10.0.2, iPhone 6. But I have seen this bug happening on other devices as well.

#11. Crashed: XPC API Misuse: Over-resume of a connection.

0 libxpc.dylib 0x187dca6b0 _xpc_api_misuse + 48

1 libxpc.dylib 0x187dca6b0 _xpc_api_misuse + 48

2 libxpc.dylib 0x187db6c08 xpc_connection_resume + 76

3 CFNetwork 0x1893b0500 -[__NSURLBackgroundSession setupXPCConnection] + 292

4 CFNetwork 0x1893b1260 -[__NSURLBackgroundSession ensureRemoteSession] + 64

5 libdispatch.dylib 0x187b6d200 _dispatch_call_block_and_release + 24

6 libdispatch.dylib 0x187b6d1c0 _dispatch_client_callout + 16

7 libdispatch.dylib 0x187b7b444 _dispatch_queue_serial_drain + 928

8 libdispatch.dylib 0x187b709a8 _dispatch_queue_invoke + 652

9 libdispatch.dylib 0x187b7b940 _dispatch_queue_override_invoke + 360

10 libdispatch.dylib 0x187b7d38c _dispatch_root_queue_drain + 572

11 libdispatch.dylib 0x187b7d0ec _dispatch_worker_thread3 + 124

12 libsystem_pthread.dylib 0x187d752c8 _pthread_wqthread + 1288

13 libsystem_pthread.dylib 0x187d74db4 start_wqthread + 4

Did this get resolved?

Which bug? The backtrace that started this thread runs through the TCP connection subsystem (

tcp_connection_create_waiting_reply
in frame 5), which looks very different from the backtrace you’re posting, which runs through NSURLSession background sessions (
-[__NSURLBackgroundSession setupXPCConnection]
in frame 3), which looks very different from the backtrace in mattie’s bug (r. 28651745).

So not sure if reporting this as a bug will help.

You should definitely file your own bug about this, even if you can’t reproduce the problem. Make sure to attach a good selection of the crash reports you’ve got.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you for your quick reply eskimo.

I have filed the bug with number: 28952752

Hi


I have similar crash log as your's. Crashed: XPC API Misuse: Over-resume of a connection. Did you ever get a solution ?

I’ll respond on the new thread you created for this.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"