NSInvalidArgumentException when using an NSConnection

Hello,


I got crash reports from my users, showing an NSInvalidArgumentException deep in NSConnection code. Unfortunately, I wasn't able to reproduce this myself, and the code works quite well whenever I test it.

Here's the exception and stack that I'm seeing:


Uncaught exception NSInvalidArgumentException (*** -[NSKeyedPortCoder initWithReceivePort:sendPort:components:]: encoded data has been corrupted, not a valid binary property list

0 com.apple.CoreFoundation 140735795579618 __exceptionPreprocess + 178
1 libobjc.A.dylib 140735859693372 objc_exception_throw + 48
2 com.apple.CoreFoundation 140735795579277 +[NSException raise:format:] + 205
3 com.apple.Foundation 140735756661201 -[NSKeyedPortCoder initWithReceivePort:sendPort:components:] + 421
4 com.apple.Foundation 140735756647694 -[NSConnection portCoderWithComponents:] + 431
5 com.apple.Foundation 140735756660300 -[NSConnection dispatchWithComponents:] + 26
6 com.apple.Foundation 140735756552276 __NSFireMachPort + 254
7 com.apple.CoreFoundation 140735794596210 __CFMachPortPerform + 290
8 com.apple.CoreFoundation 140735794595897 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
9 com.apple.CoreFoundation 140735794595753 __CFRunLoopDoSource1 + 473
10 com.apple.CoreFoundation 140735794535963 __CFRunLoopRun + 2171
11 com.apple.CoreFoundation 140735794533176 CFRunLoopRunSpecific + 296
12 com.apple.Foundation 140735756492385 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 270
13 com.dxo.******      4528234196 cli_main + 19050
14 com.dxo.******      4528214706 main + 718
15 libdyld.dylib 140735810454957 start + 1
----------------
  0x7fff98bd2000 com.apple.Foundation - /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
  0x7fff9bfd1000 libdyld.dylib - /usr/lib/system/libdyld.dylib
  0x7fff9eeb7000 libobjc.A.dylib - /usr/lib/libobjc.A.dylib
  0x7fff9b036000 com.apple.CoreFoundation - /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation


This was happening sometimes on previous OS versions, but not that much. Starting with 10.11, however, this has become the top crash for my app, and I can't find any info on this exception.


Would anyone have a clue as to what's happening here?

Are you using Distributed Objects? Or is this use of DO coming from some framework or library?

Share and Enjoy

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

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

Yes indeed, I'm using Distributed Objects. I'm spawning a new process, then sending a few requests to it through a proxy object.

Yes indeed, I'm using Distributed Objects.

OK.

Alas, I don’t have any suggestions for what might have caused this problem to start occurring more frequently. DO hasn’t changed much in recent OS releases.

Given that this represents a binary compatibility regression, I recommend that you file a bug about it with whatever information you have available to you. Please post your bug number, just for the record.

However, my recommendation is that you move away from DO. It has a number of intrinsic problems and, while it’s not formally deprecated, it should be IMO.

Share and Enjoy

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

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

We were planning to move that part of the code to use XPC, so I guess we'll fast track it 😉

The bug has been reported as rdar://25653341, just in case.

NSInvalidArgumentException when using an NSConnection
 
 
Q