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

We have the exact same problem. Haven't found any solution till now 😟

We're encountering the same issue with iOS 9, 9.01 & 9.0.2.


Stack trace is identical and we haven't found a fix yet. This looks like a bug coming from iOS9 specifically.


0 libxpc.dylib 0x0000000198ff688c _xpc_api_misuse + 48
1 libxpc.dylib 0x0000000198fe1b38 _xpc_connection_pack_message + 220
2 libxpc.dylib 0x0000000198fe1a1c xpc_connection_send_message + 76
3 libsystem_network.dylib 0x0000000198f44be0 net_helper_send + 252
4 libsystem_network.dyib 0x0000000198f3fc94 tcp_connection_create_waiting_reply + 80
5 libsystem_network.dylib 0x0000000198f42e6c __tcp_connection_allocate_block_invoke + 220
6 libsystem_network.dylib 0x0000000198f4824c __net_helper_endpoint_deliver_block_invoke_2 + 40
7 libdispatch.dylib 0x0000000198d9d7b0 _dispatch_call_block_and_release + 20
8 libdispatch.dylib 0x0000000198d9d770 _dispatch_client_callout + 12
9 libdispatch.dylib 0x0000000198da975c _dispatch_queue_drain + 860
10 libdispatch.dylib 0x0000000198da1274 _dispatch_queue_invoke + 460
11 libdispatch.dylib 0x0000000198dab62c _dispatch_root_queue_drain + 724
12 libdispatch.dylib 0x0000000198dab34c _dispatch_worker_thread3 + 108
13 libsystem_pthread.dylib 0x0000000198fb1478 _pthread_wqthread + 1088
14 libsystem_pthread.dylib 0x0000000198fb1028 start_wqthread + 0


Not sure if relevant but here's the memory usage for 1/3 of the total occurances of this bug.


224 - 256 : Has the most occurances with 15

352 - 384 : Has the less with 2


Total occurances we're counting 41 for this specific instance. There are way more with different stacktraces and therefore I can't make an aggregate just now. I'm attaching a picture but I'm not sure I this forum will display it.



I don't know where to start for debugging this or if it's better to wait for Apple to fix it. Do you know about a debugging plan to catch this kind of bugs ?


Thanks

I am seeing this as well. Not sure how to proceed.

I encounter this problem as well, anyone has idea yet?


additionlly, my crash report contain following log:


Beadcrmb Trail: (reverse chronological seconds)

9358 GC Framework: startAuthenticationForExistingPrimaryPlayer

12010 GC Framework: startAuthenticationForExistingPrimaryPlayer
15585 GC Framework: startAuthenticationForExistingPrimaryPlayer

We have been hitting this issue as well.


I am curious what is the top of the stack on your main thread when you hit this crash? For us it is in

static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)

Always got some crashes on this issue.


my crash:

Thread : Crashed: XPC API Misuse: Attempt to send a message expecting a reply to  (com.apple.networking.connection.0x176e81d0)
0  libxpc.dylib                   0x389d134a _xpc_api_misuse + 41
1  libsystem_c.dylib              0x388b09e5 __strlcpy_chk + 48
2  libxpc.dylib                   0x389c1f75 _xpc_serializer_create + 158
3  libxpc.dylib                   0x389c1ea1 xpc_connection_send_message + 60
4  libsystem_network.dylib        0x38952b39 net_helper_send + 316
5  libsystem_network.dylib        0x38946ae9 __tcp_connection_event_notify_block_invoke_2 + 16
6  libdispatch.dylib              0x38810ed7 _dispatch_call_block_and_release + 10
7  libdispatch.dylib              0x3881b04f _dispatch_queue_drain + 1762
8  libdispatch.dylib              0x3881402f _dispatch_queue_invoke + 282
9  libdispatch.dylib              0x3881c3dd _dispatch_root_queue_drain + 400
10 libdispatch.dylib              0x3881c24b _dispatch_worker_thread3 + 94
11 libsystem_pthread.dylib        0x389a5e29 _pthread_wqthread + 1024
12 libsystem_pthread.dylib        0x389a5a18 start_wqthread + 8

I know how it happened, but I have no way to fix it

From what I understand this error is related to ARC, it is caused by the xpc_release method being called one too many times.

I've noticed that the Swift Optimizer can over optimize ARC calls leading to crashes. I'm thinking that this could be related.

I don't think so. it looks like the developer write debug code。

Could you share how to reproduce this issue? How do you think that only one bug by Apple or thirdparty App issue?

Has anyone filed a bug about this? If so, please post your bug number.

Share and Enjoy

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

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

To answer my own question, at least one bug for this is (r. 22874333).

Share and Enjoy

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

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

That bug was dup’d to another (r. 21832853) which we believe is fixed in iOS 9.2. If you see crashes like this (specifically, an “XPC API Misuse” crash where the immediate cause is

net_helper_send
calling
xpc_connection_send_message
) in iOS 9.2 or later, please let us know.

Share and Enjoy

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

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

Could you share how to reproduce this issue?

Did anybody find a solution?