Unable to understand Apple Crash Log with -[NSObject(NSObject) doesNotRecognizeSelector:]

3

This is very weird, I can run my app in a simulator, iPhone 4S and iPhone 5 using Xcode 5 (5A1413) without any problems but when I submitted the app to iTunes store was rejected and this log was provided from Apple.

This is the message I got from Apple:

We found that your app crashed on iPhone 5s running iOS 7.0.2, which is not in compliance with the App Store Review Guidelines.

I confess I am clueless, can you please help me to understand this crash log:

Incident Identifier: 17461001-CE5D-451F-9BD5-FF513B76B03E
CrashReporter Key:   298a52ed29ad5cd48b1f745f998491771bd584a6
Hardware Model:      iPhone5,1
Process:             HomeClubBanesco [485]
Path:                /var/mobile/Applications/6C36584D-E12D-4BDB-995A-B1652CDA9E48/HomeClubBanesco.app/HomeClubBanesco
Identifier:          com.3pixelsmedia.HomeClubBanesco
Version:             2 (1.1)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2013-10-10 23:21:28.291 -0430
OS Version:          iOS 7.0.2 (11A501)
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x31462e86 __exceptionPreprocess + 126
1   libobjc.A.dylib                 0x3b75d6c2 objc_exception_throw + 34
2   CoreFoundation                  0x314667b2 -[NSObject(NSObject) doesNotRecognizeSelector:] + 198
3   CoreFoundation                  0x314650b2 ___forwarding___ + 702
4   CoreFoundation                  0x313b3e94 __forwarding_prep_0___ + 20
5   Foundation                      0x31e05e78 -[_NSPlaceholderData initWithData:] + 124
6   HomeClubBanesco                 0x00106b76 -[HCBAppDelegate application:didRegisterForRemoteNotificationsWithDeviceToken:] (HCBAppDelegate.m:315)
7   UIKit                           0x33efe45a _UIXXRemoteNotificationRegistrationSucceeded + 146
8   UIKit                           0x33efefc4 _XRemoteNotificationRegistrationSucceeded + 88
9   AppSupport                      0x34c73b32 migHelperRecievePortCallout + 186
10  CoreFoundation                  0x3142d77a __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30
11  CoreFoundation                  0x3142d716 __CFRunLoopDoSource1 + 342
12  CoreFoundation                  0x3142bee2 __CFRunLoopRun + 1402
13  CoreFoundation                  0x3139653c CFRunLoopRunSpecific + 520
14  CoreFoundation                  0x3139631e CFRunLoopRunInMode + 102
15  GraphicsServices                0x360cd2e6 GSEventRunModal + 134
16  UIKit                           0x33c4d1e0 UIApplicationMain + 1132
17  HomeClubBanesco                 0x00105812 main (main.m:17)
18  libdyld.dylib                   0x3bc56ab2 tlv_initializer + 2


Thread 0 Crashed:
0   libsystem_kernel.dylib          0x3bd0d1fc __pthread_kill + 8
1   libsystem_pthread.dylib         0x3bd74a4e pthread_kill + 54
2   libsystem_c.dylib               0x3bcbe028 abort + 72
3   libc++abi.dylib                 0x3b10c98a abort_message + 70
4   libc++abi.dylib                 0x3b1256e2 default_terminate_handler() + 250
5   libobjc.A.dylib                 0x3b75d936 _objc_terminate() + 190
6   libc++abi.dylib                 0x3b1231b0 std::__terminate(void (*)()) + 76
7   libc++abi.dylib                 0x3b122d12 __cxa_rethrow + 98
8   libobjc.A.dylib                 0x3b75d80a objc_exception_rethrow + 38
9   CoreFoundation                  0x313965b2 CFRunLoopRunSpecific + 638
10  CoreFoundation                  0x3139631e CFRunLoopRunInMode + 102
11  GraphicsServices                0x360cd2e6 GSEventRunModal + 134
12  UIKit                           0x33c4d1e0 UIApplicationMain + 1132
13  HomeClubBanesco                 0x00105812 main (main.m:17)
14  libdyld.dylib                   0x3bc56ab4 start + 0

Thread 1:
0   libsystem_kernel.dylib          0x3bcfa838 kevent64 + 24
1   libdispatch.dylib               0x3bc490d0 _dispatch_mgr_invoke + 228
2   libdispatch.dylib               0x3bc4363e _dispatch_mgr_thread + 34

Thread 2:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 3:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 4:
0   libsystem_kernel.dylib          0x3bcfaa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3bcfa87c mach_msg + 36
2   CoreFoundation                  0x3142d55c __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x3142bc7c __CFRunLoopRun + 788
4   CoreFoundation                  0x3139653c CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x313da1a6 CFRunLoopRun + 94
6   CoreMotion                      0x31a4e394 ___lldb_unnamed_function1407$$CoreMotion + 724
7   libsystem_pthread.dylib         0x3bd73c5a _pthread_body + 138
8   libsystem_pthread.dylib         0x3bd73bca _pthread_start + 98
9   libsystem_pthread.dylib         0x3bd71ccc thread_start + 4

Thread 5 name:  com.apple.NSURLConnectionLoader
Thread 5:
0   libsystem_kernel.dylib          0x3bcfaa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3bcfa87c mach_msg + 36
2   CoreFoundation                  0x3142d55c __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x3142bc7c __CFRunLoopRun + 788
4   CoreFoundation                  0x3139653c CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x3139631e CFRunLoopRunInMode + 102
6   Foundation                      0x31dd164c +[NSURLConnection(Loader) _resourceLoadLoop:] + 316
7   Foundation                      0x31e46dc2 __NSThread__main__ + 1058
8   libsystem_pthread.dylib         0x3bd73c5a _pthread_body + 138
9   libsystem_pthread.dylib         0x3bd73bca _pthread_start + 98
10  libsystem_pthread.dylib         0x3bd71ccc thread_start + 4

Thread 6:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 7:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 8:
0   libsystem_kernel.dylib          0x3bd0dc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3bd71e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3bd71cc0 start_wqthread + 4

Thread 9 name:  com.apple.CFSocket.private
Thread 9:
0   libsystem_kernel.dylib          0x3bd0d440 select$DARWIN_EXTSN + 20
1   CoreFoundation                  0x3143145e __CFSocketManager + 482
2   libsystem_pthread.dylib         0x3bd73c5a _pthread_body + 138
3   libsystem_pthread.dylib         0x3bd73bca _pthread_start + 98
4   libsystem_pthread.dylib         0x3bd71ccc thread_start + 4

Thread 0 crashed with ARM Thread State (32-bit):
    r0: 0x00000000    r1: 0x00000000      r2: 0x00000000      r3: 0x00002060
    r4: 0x00000006    r5: 0x3db3a18c      r6: 0x00000000      r7: 0x27d03584
    r8: 0x15e958a0    r9: 0x00000001     r10: 0x31f15124     r11: 0x00000000
    ip: 0x00000148    sp: 0x27d03578      lr: 0x3bd74a53      pc: 0x3bd0d1fc
  cpsr: 0x00000010

Updated to show the broken method

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

 NSLog(@"Usuario SI Acepto las notificaciones");
[self setDToken:deviceToken];
NSData *myToken = [[NSData alloc] initWithData:[[NSUserDefaults standardUserDefaults] objectForKey:HCBDeviceTokenPrefKey]];
if (![myToken isEqualToData:deviceToken]) {
    NSLog(@"Token no coincide");
        [[NSUserDefaults standardUserDefaults] setObject:deviceToken forKey:HCBDeviceTokenPrefKey];
    // Debo actualizar los datos en la db.
    if (![[[NSUserDefaults standardUserDefaults] objectForKey:HCBUserIDPrefKey] isEqualToString:@"1"]) {
        NSString *urlString = [NSString stringWithFormat:@"http://cmx.3pixelsmedia.com/homeclub/?l=iphone&updateDeviceID&deviceToken=%@&userID=%@",
                               deviceToken,
                               [[NSUserDefaults standardUserDefaults] objectForKey:HCBUserIDPrefKey]];
        NSLog(@"urlString : %@",urlString);
    }
}

NSLog(@"Device Token : %@",myToken);
}
ios
ios7
crash-reports
asked on Stack Overflow Oct 11, 2013 by cromanelli • edited Apr 17, 2019 by Cœur

1 Answer

1

During app review, your app received a EXC_CRASH (SIGABRT) exception. That means the code running in your app detected a fault and so it asked the Operating System to terminate your process, which is does via a SIGABRT signal.

The origin of the abort was that the Objective-C runtime detected a doesNotRecognizeSelector problem when dispatching a method request, as seen in the exception backtrace

2   CoreFoundation                  0x314667b2 -[NSObject(NSObject) doesNotRecognizeSelector:] + 198

The code that gave rise to this is:

NSData *myToken = [[NSData alloc] initWithData:[[NSUserDefaults standardUserDefaults] objectForKey:HCBDeviceTokenPrefKey]];

That is because NSData will assume the user defaults has NSData result for the device token. If it does not get an appropriate NSData object it will send an -[_NSPlaceholderData initWithData:] constructor message to an object that does not know about this private implementation class for NSData

Just to double-check the following test code proves this experimentally:

NSData *myToken = [[NSData alloc] initWithData:[[NSUserDefaults standardUserDefaults] objectForKey:@"SomeKey"]];

NSLog(@"My data is %@ - ok since we can handle a nil", myToken);

id stringProperty = @"Some string";
NSData *problemToken = [[NSData alloc] initWithData:stringProperty];

NSLog(@"My data is %@ - we have probably crashed by now", problemToken);

Taking a step back, it is important to understand crashes can often occur not due to your code itself, but instead the environment your code is running in.

Two factors are different between your working and failing case.

  1. Your app locally may have from a prior run setup its user defaults with a NSData token.
  2. Your app local testing may be using a Debug version which has been configured (in terms of defaults) differently from your Release version (which will have been sent to Apple).

Things to try:

  1. In simulator, erase contents and settings and re-try your app.
  2. In Xcode (Schema settings) change your deployment version from Debug to Release.
  3. Put in code which tests the type of the value come from User Defaults for key HCBUserIDPrefKey. Ensure that it is NSData (also check for nil).
answered on Stack Overflow Jul 26, 2018 by Faisal Memon

User contributions licensed under CC BY-SA 3.0