EXC_CRASH (SIGABRT) - EXC_CORPSE_NOTIFY

Hi! I got my app rejected because of EXC_CRASH (SIGABRT) - EXC_CORPSE_NOTIFY. I symbolicated the crash log and it is below:


{"app_name":"Animals for Kids","timestamp":"2019-09-20 08:14:52.69 -0700","app_version":"1.0","slice_uuid":"ad5fbb98-35eb-383d-9da8-90bd9623c96a","adam_id":1437889818,"build_version":"1","bundleID":"com.feasyapps.animalsforkids","share_with_app_devs":false,"is_first_party":false,"bug_type":"109","os_version":"iPhone OS 12.4.1 (16G102)","incident_id":"A747B4FC-4970-4F35-9FA6-6313FDEEAC7F","name":"Animals for Kids"}
Incident Identifier: A747B4FC-4970-4F35-9FA6-6313FDEEAC7F
CrashReporter Key:   70449b7e2719c9289208e00c8c942cf05428f73d
Hardware Model:      ***
Process:             Animals for Kids [5372]
Path:                /private/var/containers/Bundle/Application/EC1D83B9-8A09-4622-A995-7D979D3B2138/Animals for Kids.app/Animals for Kids
Identifier:          com.feasyapps.animalsforkids
Version:             1 (1.0)
AppStoreTools:       11A1002b
Code Type:           ARM-64 (Native)
Role:                Non UI
Parent Process:      launchd [1]
Coalition:           com.feasyapps.animalsforkids [2249]




Date/Time:           2019-09-20 08:14:52.5136 -0700
Launch Time:         2019-09-20 08:12:38.3761 -0700
OS Version:          iPhone OS 12.4.1 (16G102)
Baseband Version:    7.80.04
Report Version:      104


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


Application Specific Information:
abort() called


Last Exception Backtrace:
0   CoreFoundation                0x23998198c __exceptionPreprocess + 228
1   libobjc.A.dylib                0x238b5a9f8 objc_exception_throw + 55
2   CoreFoundation                0x239896ecc -[__NSArray0 objectAtIndex:] + 107
3   libswiftCore.dylib            0x267115dbc _CocoaArrayWrapper.subscript.getter + 31
4   Animals for Kids              0x1002ad5a4 specialized _ArrayBuffer._getElementSlowPath(_:) + 316836 (<compiler-generated>:0)
5   Animals for Kids              0x1002ac1f0 closure #1 in IAPController.requestProducts() + 311792 (<compiler-generated>:0)
6   Animals for Kids              0x1002869c4 specialized IAPHelper.productsRequest(_:didReceive:) + 158148 (IAPHelper.swift:70)
7   Animals for Kids              0x100285830 @objc IAPHelper.productsRequest(_:didReceive:) + 153648 (<compiler-generated>:69)
8   StoreKit                      0x24d488b40 __34-[SKProductsRequest _handleReply:]_block_invoke + 503
9   libdispatch.dylib              0x2393bfa38 _dispatch_call_block_and_release + 23
10  libdispatch.dylib              0x2393c07d4 _dispatch_client_callout + 15
11  libdispatch.dylib              0x23936e008 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1067
12  CoreFoundation                0x23991332c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11
13  CoreFoundation                0x23990e264 __CFRunLoopRun + 1923
14  CoreFoundation                0x23990d7c0 CFRunLoopRunSpecific + 435
15  GraphicsServices              0x23bb0e79c GSEventRunModal + 103
16  UIKitCore                      0x265fc6c38 UIApplicationMain + 211
17  Animals for Kids              0x1002649f8 main + 18936 (LearnController+UICollectionViewDelegate.swift:14)
18  libdyld.dylib                  0x2393d18e0 start + 3




Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib        0x000000023951e0dc __pthread_kill + 8
1   libsystem_pthread.dylib        0x0000000239597094 pthread_kill$VARIANT$mp + 380
2   libsystem_c.dylib              0x0000000239476f4c __abort + 152
3   libsystem_c.dylib              0x0000000239476eb4 __abort + 0
4   libc++abi.dylib                0x0000000238b43788 __cxa_bad_cast + 0
5   libc++abi.dylib                0x0000000238b43934 default_unexpected_handler+ 6452 () + 0
6   libobjc.A.dylib                0x0000000238b5ae00 _objc_terminate+ 24064 () + 124
7   Animals for Kids              0x00000001002dac44 CLSTerminateHandler() + 502852 (CLSException.mm:0)
8   libc++abi.dylib                0x0000000238b4f838 std::__terminate(void (*)+ 55352 ()) + 16
9   libc++abi.dylib                0x0000000238b4f8c4 std::terminate+ 55492 () + 84
10  libdispatch.dylib              0x00000002393c07e8 _dispatch_client_callout + 36
11  libdispatch.dylib              0x000000023936e008 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068
12  CoreFoundation                0x000000023991332c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
13  CoreFoundation                0x000000023990e264 __CFRunLoopRun + 1924
14  CoreFoundation                0x000000023990d7c0 CFRunLoopRunSpecific + 436
15  GraphicsServices              0x000000023bb0e79c GSEventRunModal + 104
16  UIKitCore                      0x0000000265fc6c38 UIApplicationMain + 212
17  Animals for Kids              0x00000001002649f8 main + 18936 (LearnController+UICollectionViewDelegate.swift:14)
18  libdyld.dylib                  0x00000002393d18e0 start + 4


Thread 1 name:  com.apple.uikit.eventfetch-thread
Thread 1:
0   libsystem_kernel.dylib        0x00000002395130f4 mach_msg_trap + 8
1   libsystem_kernel.dylib        0x00000002395125a0 mach_msg + 72
2   CoreFoundation                0x0000000239913120 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                0x000000023990e030 __CFRunLoopRun + 1360
4   CoreFoundation                0x000000023990d7c0 CFRunLoopRunSpecific + 436
5   Foundation                    0x000000023a2db98c -[NSRunLoop+ 31116 (NSRunLoop) runMode:beforeDate:] + 300
6   Foundation                    0x000000023a2db81c -[NSRunLoop+ 30748 (NSRunLoop) runUntilDate:] + 96
7   UIKitCore                      0x00000002660ac754 -[UIEventFetcher threadMain] + 136
8   Foundation                    0x000000023a4084a0 __NSThread__start__ + 984
9   libsystem_pthread.dylib        0x00000002395a02c0 _pthread_body + 128
10  libsystem_pthread.dylib        0x00000002395a0220 _pthread_start + 44
11  libsystem_pthread.dylib        0x00000002395a3cdc thread_start + 4


Thread 2 name:  com.twitter.crashlytics.ios.MachExceptionServer
Thread 2:
0   libsystem_kernel.dylib        0x00000002395130f4 mach_msg_trap + 8
1   libsystem_kernel.dylib        0x00000002395125a0 mach_msg + 72
2   Animals for Kids              0x00000001002c8284 CLSMachExceptionServer + 426628 (CLSMachException.c:180)
3   libsystem_pthread.dylib        0x00000002395a02c0 _pthread_body + 128
4   libsystem_pthread.dylib        0x00000002395a0220 _pthread_start + 44
5   libsystem_pthread.dylib        0x00000002395a3cdc thread_start + 4


Thread 3 name:  com.apple.NSURLConnectionLoader
Thread 3:
0   libsystem_kernel.dylib        0x00000002395130f4 mach_msg_trap + 8
1   libsystem_kernel.dylib        0x00000002395125a0 mach_msg + 72
2   CoreFoundation                0x0000000239913120 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                0x000000023990e030 __CFRunLoopRun + 1360
4   CoreFoundation                0x000000023990d7c0 CFRunLoopRunSpecific + 436
5   CFNetwork                      0x0000000239f2774c -[__CoreSchedulingSetRunnable runForever] + 216
6   Foundation                    0x000000023a4084a0 __NSThread__start__ + 984
7   libsystem_pthread.dylib        0x00000002395a02c0 _pthread_body + 128
8   libsystem_pthread.dylib        0x00000002395a0220 _pthread_start + 44
9   libsystem_pthread.dylib        0x00000002395a3cdc thread_start + 4


Thread 4 name:  AVAudioSession Notify Thread
Thread 4:
0   libsystem_kernel.dylib        0x00000002395130f4 mach_msg_trap + 8
1   libsystem_kernel.dylib        0x00000002395125a0 mach_msg + 72
2   CoreFoundation                0x0000000239913120 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                0x000000023990e030 __CFRunLoopRun + 1360
4   CoreFoundation                0x000000023990d7c0 CFRunLoopRunSpecific + 436
5   AVFAudio                      0x000000023f87f334 GenericRunLoopThread::Entry+ 574260 (void*) + 156
6   AVFAudio                      0x000000023f8a9c60 CAPThread::Entry+ 748640 (CAPThread*) + 88
7   libsystem_pthread.dylib        0x00000002395a02c0 _pthread_body + 128
8   libsystem_pthread.dylib        0x00000002395a0220 _pthread_start + 44
9   libsystem_pthread.dylib        0x00000002395a3cdc thread_start + 4


Thread 5 name:  com.apple.coreaudio.AQClient
Thread 5:
0   libsystem_kernel.dylib        0x00000002395130f4 mach_msg_trap + 8
1   libsystem_kernel.dylib        0x00000002395125a0 mach_msg + 72
2   CoreFoundation                0x0000000239913120 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                0x000000023990e030 __CFRunLoopRun + 1360
4   CoreFoundation                0x000000023990d7c0 CFRunLoopRunSpecific + 436
5   AudioToolbox                  0x000000023da127bc GenericRunLoopThread::Entry+ 2299836 (void*) + 156
6   AudioToolbox                  0x000000023dca14f8 CAPThread::Entry+ 4982008 (CAPThread*) + 88
7   libsystem_pthread.dylib        0x00000002395a02c0 _pthread_body + 128
8   libsystem_pthread.dylib        0x00000002395a0220 _pthread_start + 44
9   libsystem_pthread.dylib        0x00000002395a3cdc thread_start + 4


Thread 6:
0   libsystem_pthread.dylib        0x00000002395a3cd0 start_wqthread + 0


Thread 7:
0   libsystem_pthread.dylib        0x00000002395a3cd0 start_wqthread + 0


Thread 8:
0   libsystem_pthread.dylib        0x00000002395a3cd0 start_wqthread + 0


Thread 9:
0   libsystem_pthread.dylib        0x00000002395a3cd0 start_wqthread + 0


Thread 10 name:  AXSpeech
Thread 10:
0   libsystem_kernel.dylib        0x00000002395130f4 mach_msg_trap + 8
1   libsystem_kernel.dylib        0x00000002395125a0 mach_msg + 72
2   CoreFoundation                0x0000000239913120 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                0x000000023990e030 __CFRunLoopRun + 1360
4   CoreFoundation                0x000000023990d7c0 CFRunLoopRunSpecific + 436
5   Foundation                    0x000000023a2db98c -[NSRunLoop+ 31116 (NSRunLoop) runMode:beforeDate:] + 300
6   libAXSpeechManager.dylib      0x000000024962894c -[AXSpeechThread main] + 264
7   Foundation                    0x000000023a4084a0 __NSThread__start__ + 984
8   libsystem_pthread.dylib        0x00000002395a02c0 _pthread_body + 128
9   libsystem_pthread.dylib        0x00000002395a0220 _pthread_start + 44
10  libsystem_pthread.dylib        0x00000002395a3cdc thread_start + 4


Thread 11 name:  AXSpeech
Thread 11:
0   libsystem_kernel.dylib        0x00000002395130f4 mach_msg_trap + 8
1   libsystem_kernel.dylib        0x00000002395125a0 mach_msg + 72
2   CoreFoundation                0x0000000239913120 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                0x000000023990e030 __CFRunLoopRun + 1360
4   CoreFoundation                0x000000023990d7c0 CFRunLoopRunSpecific + 436
5   Foundation                    0x000000023a2db98c -[NSRunLoop+ 31116 (NSRunLoop) runMode:beforeDate:] + 300
6   libAXSpeechManager.dylib      0x000000024962894c -[AXSpeechThread main] + 264
7   Foundation                    0x000000023a4084a0 __NSThread__start__ + 984
8   libsystem_pthread.dylib        0x00000002395a02c0 _pthread_body + 128
9   libsystem_pthread.dylib        0x00000002395a0220 _pthread_start + 44
10  libsystem_pthread.dylib        0x00000002395a3cdc thread_start + 4


Thread 12:
0   libsystem_kernel.dylib        0x00000002395130f4 mach_msg_trap + 8
1   libsystem_kernel.dylib        0x00000002395125a0 mach_msg + 72
2   CoreFoundation                0x0000000239913120 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                0x000000023990e030 __CFRunLoopRun + 1360
4   CoreFoundation                0x000000023990d7c0 CFRunLoopRunSpecific + 436
5   TTSSpeechBundle                0x00000001062229e4 0x106200000 + 141796
6   libsystem_pthread.dylib        0x00000002395a02c0 _pthread_body + 128
7   libsystem_pthread.dylib        0x00000002395a0220 _pthread_start + 44
8   libsystem_pthread.dylib        0x00000002395a3cdc thread_start + 4


Thread 13:
0   libsystem_pthread.dylib        0x00000002395a3cd0 start_wqthread + 0


Thread 14:
0   libsystem_pthread.dylib        0x00000002395a3cd0 start_wqthread + 0


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000001
    x4: 0x0000000000000000   x5: 0x0000000000989680   x6: 0x000000000000006e   x7: 0xffffffffffffffec
    x8: 0x0000000000000800   x9: 0x0000000000000000  x10: 0x00000000000003e8  x11: 0x0000000000000003
   x12: 0x0000000000000000  x13: 0x0000000000000001  x14: 0x0000000000000010  x15: 0x000000000000005f
   x16: 0x0000000000000148  x17: 0x0000000000000000  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000100842bc0  x21: 0x000000016fb9e650  x22: 0x0000000000000303  x23: 0x0000000100842ca0
   x24: 0x0000000000000001  x25: 0x0000000100842ca0  x26: 0x0000000000000114  x27: 0x0000000000000000
   x28: 0x0000000282c451c0   fp: 0x000000016fb9e570   lr: 0x0000000239597094
    sp: 0x000000016fb9e540   pc: 0x000000023951e0dc cpsr: 0x00000000


I guess there is a problem in the method below but I can't figure what it could be. Can I have some help? Thank you.


private func requestProducts() {
        activityIndicator.startAnimating()
        
        IAPHelper.shared.requestProducts([IAPProduct.nonConsumableFullVersion1]) { (response, error) in
            if let error = error {
                self.presentErrorAlertView(error: error.localizedDescription)
                self.activityIndicator.stopAnimating()
                return
            }
            
            if let product = response?.products[0] {
                let title = NSAttributedString(string: "\(NSLocalizedString("buy", comment: "Buy"))\n\(product.localizedPrice ?? "0")",
                    attributes: [NSAttributedString.Key.foregroundColor: UIColor.golderFizz])
                self.purchaseButton.setAttributedTitle(title, for: .normal)
                self.activityIndicator.stopAnimating()
            }
        }
    }

Replies

It's crashing because you're trying to access an array index beyond that actual limits of some array. Assuming it's in the method you showed (you can symbolicate your crash log to be sure), the only obvious place for that kind of failure is line 11, which will crash if the products array is empty.


One way around this is to write it as:


            if let product = response?.products.first {


products.first is the same as products[0], except that it's nil if the array is empty. In that case, your "if let" test will skip lines 12-15.


Of course, that might not be the right thing to do if the array is empty. You might want to do some error handling instead.