Reputation: 8636
I have some days now this strange problem 2014-03-24 16:50:56.097 MyApp[1610:4703] -[__NSCFBoolean length]: unrecognized selector sent to instance 0x1f54358
.
I have debugging my library, which is a static library where I package as a .framework and distribute to developers.
Debugging is little hard, in point of breakpoints, so I have added the static library .xcodeproj file to a sample client application and tried to work with it. After some research and trying to figure out where this is occur I have no other reason than believe that it's an AFNetworking problem!
I have this code in my static library:
EDITED:
// Selector parameter (NSData *)theData
NSMutableURLRequest *aRequest = [[[NSMutableURLRequest alloc] initWithURL:theURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0f] autorelease];
[aRequest setHTTPMethod:@"POST"];
[aRequest setValue:key forHTTPHeaderField:@"Custom-Header"];
[aRequest setValue:@"plain/text" forHTTPHeaderField:@"Content-Type"];
NSMutableData *postData = [NSMutableData data];
[postData appendData:theData];
[aRequest setHTTPBody:postData];
AFHTTPRequestOperation* operation = [[AFHTTPRequestOperation alloc] initWithRequest:aRequest];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
_pendingDispatchesCount --;
NSLog(@"%@, %ld", kServerRespondedMsg, (long)operation.response.statusCode);
BOOL statusCodeAcceptable = [[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)] containsIndex:[operation.response statusCode]];
dispatch_async(dispatch_get_main_queue(),
^{
[delegate analyticsOperationCompleted:statusCodeAcceptable forData:analyticsData];
});
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
_pendingDispatchesCount --;
NSLog(@"%@, %ld", kServerRespondedMsg, (long)operation.response.statusCode);
dispatch_async(dispatch_get_main_queue(),
^{
[delegate analyticsOperationCompleted:NO forData:analyticsData];
});
}];
[operation start];
If I just comment the [operation start];
the sample client starts properly. If I let the operation to start I get the 2014-03-24 16:50:56.097 MyApp[1610:4703] -[__NSCFBoolean length]: unrecognized selector sent to instance
.
Drives me crazy at the moment, because this error occurs only to one developer where he reported it and he actually created a sample that reproduces it.
EDIT: Found a way to get the stacktrace and it seems that this is not caused by my application:
Backtrace:
0 CoreFoundation 0x000000010201c495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101d7b99e objc_exception_throw + 43
2 CoreFoundation 0x00000001020ad65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010200dd8d ___forwarding___ + 973
4 CoreFoundation 0x000000010200d938 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x000000010200e9d1 CFURLCreateStringByAddingPercentEscapes + 81
6 CFNetwork 0x0000000103fdf1ab _ZL13appendEscapedP10__CFStringPKS_ + 40
7 CFNetwork 0x0000000103fdef69 _ZL25initializeUserAgentStringv + 124
8 libsystem_pthread.dylib 0x00000001026d58d6 __pthread_once_handler + 65
9 libsystem_platform.dylib 0x00000001025e3156 _os_once + 73
10 libsystem_pthread.dylib 0x00000001026d5875 pthread_once + 57
11 CFNetwork 0x0000000103fdeb23 cleanUpRequest + 105
12 CFNetwork 0x0000000103fde824 _ZN17HTTPNetConnection19prepareTransmissionEP17HTTPNetStreamInfoP17__CoreWriteStream + 1224
13 CFNetwork 0x0000000103fdda65 _ZN13NetConnection7enqueueEPvh + 539
14 CFNetwork 0x0000000103fdd7e4 _ZN17HTTPNetStreamInfo16_streamImpl_OpenEP13CFStreamErrorPh + 88
15 CFNetwork 0x000000010403c295 _ZThn120_N17HTTPNetStreamInfo16_streamImpl_OpenEP13CFStreamErrorPh + 13
16 CFNetwork 0x0000000103fbdfc2 _ZN14CoreStreamBase21_streamInterface_OpenEv + 80
17 CFNetwork 0x0000000103fdd057 _ZN12HTTPProtocol10openStreamEv + 255
18 CFNetwork 0x0000000104048c41 _ZN12HTTPProtocol26useNetConnectionForRequestEP13NetConnectionP15__CFHTTPMessageh + 1753
19 CFNetwork 0x0000000103fdc268 _ZN24HTTPConnectionCacheEntry28dispatchConnectionToProtocolEP13NetConnectionP12HTTPProtocolP18HTTPRequestMessageh + 276
20 CFNetwork 0x0000000103fdc027 _ZN24HTTPConnectionCacheEntry34notifyNextProtocolOfOpenConnectionEP13NetConnectionh + 301
21 CFNetwork 0x0000000103fd9230 _ZN24HTTPConnectionCacheEntry25enqueueRequestForProtocolEP12HTTPProtocolP15__CFHTTPMessage + 650
22 CFNetwork 0x0000000103fd8bf0 _ZN19HTTPConnectionCache34_onqueue_enqueueRequestForProtocolEP12HTTPProtocolP15__CFHTTPMessage + 178
23 CFNetwork 0x000000010404e843 ___ZN19HTTPConnectionCache25enqueueRequestForProtocolEP12HTTPProtocolP15__CFHTTPMessage_block_invoke + 26
24 CoreFoundation 0x0000000101fc2f74 CFArrayApplyFunction + 68
25 CFNetwork 0x0000000103fd43e7 _ZN19RunloopBlockContext7performEv + 133
26 CFNetwork 0x0000000103fd4217 _ZN17MultiplexerSource7performEv + 247
27 CFNetwork 0x0000000103fd403a _ZN17MultiplexerSource8_performEPv + 72
28 CoreFoundation 0x0000000101fabd21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
29 CoreFoundation 0x0000000101fab5f2 __CFRunLoopDoSources0 + 242
30 CoreFoundation 0x0000000101fc746f __CFRunLoopRun + 767
31 CoreFoundation 0x0000000101fc6d83 CFRunLoopRunSpecific + 467
32 Foundation 0x000000010193089c +[NSURLConnection(Loader) _resourceLoadLoop:] + 348
33 Foundation 0x00000001019832df __NSThread__main__ + 1167
34 libsystem_pthread.dylib 0x00000001026d4899 _pthread_body + 138
35 libsystem_pthread.dylib 0x00000001026d472a _pthread_struct_init + 0
36 libsystem_pthread.dylib 0x00000001026d8fc9 thread_start + 13
EDITED: Link with the full PLCrashReporter crash report symbolicated. https://drive.google.com/file/d/0B_4YDWJioTI1c0hia25NSXFTWVk/edit?usp=sharing
Any help or thought appreciated, thanks in advance.
Regards.
Upvotes: 0
Views: 1822
Reputation: 52612
Look at the stack trace and think about what might go on. The stack trace is not some magical thing, it's something directly related to your code.
The crash is caused by someone sending a "length" message to an NSNumber
containing a Boolean
value.
On the stack trace we see CFURLCreateStringByAddingPercentEscapes
. So it seems that CFURLCreateStringByAddingPercentEscapes
was called with an NSNumber
object instead of a string.
Why would CFURLCreateStringByAddingPercentEscapes
be called? It's usually called for strings containing URLs and similar things that cannot be transmitted as they are and need translating, like space to %20.
So you probably passed an NSNumber
to something that would be sent over the network. Like a header property, a URL
, and so on.
Go through all the things that you set up in the URL
request. Problem is probably in the "aRequest", especially since you decided to hide it. (That's the subconscious mind not wanting us to see your mistake which is of course counter-productive here).
Upvotes: 2