Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 9: Crash on -[_NSXPCDistantObject methodSignatureForSelector:]

I'm getting a strange bug:

Fatal Exception: NSInvalidArgumentException *** -[_NSXPCDistantObject methodSignatureForSelector:]: No protocol has been set on connection connection to service named com.apple.nsurlsessiond"

This issue only appears to be happening on iOS 9. According to the stack trace, the bug is triggered by a call to -[UIApplication _sendWillEnterForegroundCallbacks].

Thread : Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 6485512008 __exceptionPreprocess
1  libobjc.A.dylib                6833323904 objc_exception_throw
2  CoreFoundation                 6485511824 -[NSException initWithCoder:]
3  Foundation                     6500536092 -[_NSXPCDistantObject methodSignatureForSelector:]
4  CoreFoundation                 6485526892 ___forwarding___
5  CoreFoundation                 6484495532 _CF_forwarding_prep_0
6  CoreFoundation                 6485141004 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
7  CoreFoundation                 6485138988 _CFXRegistrationPost
8  CoreFoundation                 6485138348 ___CFXNotificationPost_block_invoke
9  CoreFoundation                 6485554212 -[_CFXNotificationRegistrar find:object:observer:enumerator:]
10 CoreFoundation                 6484354836 _CFXNotificationPost
11 Foundation                     6500543948 -[NSNotificationCenter postNotificationName:object:userInfo:]
12 UIKit                          6577878356 -[UIApplication _sendWillEnterForegroundCallbacks]
   continues ... 

So it would appear that when the app will enter foreground, some observer registered tries to reconnect with nsurlsessiond over via RPC and fails? I do a background transfer session using NSURLSession, but I'm unable to reproduce this so I'm not sure if it's related or not.

Has anyone seen this issue before? Is there anything I can do to address it?

like image 850
bcattle Avatar asked Nov 14 '15 00:11

bcattle


1 Answers

Looks like a bug in iOS described here: https://forums.developer.apple.com/thread/45651#140745

AFAICT this crash is caused by NSURLSession’s background session support. This passes work to its daemon (nsurlsessiond) using NSXPCConnection (not part of the iOS SDK, but public API on OS X, so you can read up about it there). NSXPCConnection has the notion of interrupted connections, that is, the IPC connection between the client and the server has torn but can be re-established. NSURLSession’s background session support, like all NSXPCConnection clients, must handle these interruptions as a matter of course. Alas, there’s a bug in the way it does that. This bug is a race condition that manifest itself as this crash. We hope to fix this in a future OS release but I can’t share any concrete details.

like image 112
zh. Avatar answered Oct 08 '22 10:10

zh.