Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKStoreKit crash on iOS 7 with SIGTRAP error

I have been over and over this live app crash log and cannot find the problem:

1    CoreFoundation  _CFHash + 130
2    CoreFoundation  CFBasicHashFindBucket + 724
3    CoreFoundation  _CFDictionaryGetValue + 99
4    CoreFoundation  -[CFXPreferencesPropertyListSource setValue:forKey:] + 39
5    CoreFoundation  _CFXPreferencesSetValue + 139
6    CoreFoundation  _CFPreferencesSetAppValue + 45
7    Foundation  -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 61
8    MyApp   -[MKStoreManager rememberPurchaseOfProduct:withReceipt:] (MKStoreManager.m:884)
9    MyApp   -[MKStoreManager provideContent:forReceipt:hostedContent:] (MKStoreManager.m:848)
10   MyApp   -[MKStoreManager restoreTransaction:] (MKStoreManager.m:1004)
11   MyApp   -[MKStoreManager paymentQueue:updatedTransactions:] (MKStoreManager.m:911)
12   StoreKit    __NotifyObserverAboutChanges + 85

Here is the code that I believe is associated with the crash(es!):

- (void)rememberPurchaseOfProduct:(NSString*) productIdentifier withReceipt:(NSData*) receiptData {

    NSDictionary *allConsumables = [[MKStoreManager storeKitItems] objectForKey:@"Consumables"];
    if([[allConsumables allKeys] containsObject:productIdentifier])
    {
        NSDictionary *thisConsumableDict = [allConsumables objectForKey:productIdentifier];
        NSInteger quantityPurchased = [[thisConsumableDict objectForKey:@"Count"] integerValue];
        NSString* productPurchased = [thisConsumableDict objectForKey:@"Name"];

        NSInteger oldCount = [[MKStoreManager numberForKey:productPurchased] integerValue];
        NSInteger newCount = oldCount + quantityPurchased;

        [MKStoreManager setObject:[NSNumber numberWithInteger:newCount] forKey:productPurchased];
    }
    else
    {
        [MKStoreManager setObject:[NSNumber numberWithBool:YES] forKey:productIdentifier];

        //set flag in NSUserDefaults as another place we chan check to see if they have purchased the app
        //we may not want to check this, however, as an OR, since it can be easily jailbroken
        [[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:productIdentifier];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

    [MKStoreManager setObject:receiptData forKey:[NSString stringWithFormat:@"%@-receipt", productIdentifier]];
}

I have been using this same code for years with no problem. Can anyone please help to point me in the right direction?

UPDATE: posting full crash log below

Incident Identifier: 07EF534E-E37C-4AF3-982A-11D6997A0D5C
CrashReporter Key:   CE01293A-021D-4DAD-BFA9-7F24957608B7
Hardware Model:      iPhone6,1
Process:         MyApp [1590]
Path:            /Users/USER/MyApp.app/MyApp
Identifier:      com.mysoftware.myapp
Version:         1.3.1
Code Type:       ARM
Parent Process:  launchd [1]

Date/Time:       2013-11-04T18:31:48Z
OS Version:      iPhone OS 7.0.3 (11B511)
Report Version:  104

Exception Type:  SIGTRAP
Exception Codes: #0 at 0x2fdd01be
Crashed Thread:  0

Thread 0 Crashed:
0   CoreFoundation                      0x2fdd01be _CFHash + 130
1   CoreFoundation                      0x2fdccb6c CFBasicHashFindBucket + 724
2   CoreFoundation                      0x2fdcc873 _CFDictionaryGetValue + 99
3   CoreFoundation                      0x2fe14ab3 -[CFXPreferencesPropertyListSource setValue:forKey:] + 39
4   CoreFoundation                      0x2fe14a2f _CFXPreferencesSetValue + 139
5   CoreFoundation                      0x2fe14905 _CFPreferencesSetAppValue + 45
6   Foundation                          0x307d0a55 -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 61
7   MyApp                         0x00134d59 -[MKStoreManager rememberPurchaseOfProduct:withReceipt:] (MKStoreManager.m:884)
8   MyApp                         0x0013496d -[MKStoreManager provideContent:forReceipt:hostedContent:] (MKStoreManager.m:848)
9   MyApp                         0x0013538f -[MKStoreManager restoreTransaction:] (MKStoreManager.m:1004)
10  MyApp                         0x00134ed5 -[MKStoreManager paymentQueue:updatedTransactions:] (MKStoreManager.m:911)
11  StoreKit                            0x325b6e85 __NotifyObserverAboutChanges + 85
12  CoreFoundation                      0x2fdd2ea1 _CFArrayApplyFunction + 37
13  StoreKit                            0x325b6e21 -[SKPaymentQueue _notifyObserversAboutChanges:sendUpdatedDownloads:] + 129
14  StoreKit                            0x325b76f9 -[SKPaymentQueue _processUpdates:trimUnmatched:sendUpdatedDownloads:] + 1017
15  StoreKit                            0x325b7dc9 -[SKPaymentQueue _setTransactionsWithReply:] + 129
16  StoreKit                            0x325b69bf __38-[SKPaymentQueue _establishConnection]_block_invoke_2 + 63
17  libdispatch.dylib                   0x3a6e50c3 _dispatch_call_block_and_release + 11
18  libdispatch.dylib                   0x3a6e50af _dispatch_client_callout + 23
19  libdispatch.dylib                   0x3a6e79a9 __dispatch_main_queue_callback_4CF + 269
20  CoreFoundation                      0x2fe6a5b1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
21  CoreFoundation                      0x2fe68e7d __CFRunLoopRun + 1309
22  CoreFoundation                      0x2fdd3471 _CFRunLoopRunSpecific + 525
23  CoreFoundation                      0x2fdd3253 _CFRunLoopRunInMode + 107
24  GraphicsServices                    0x34b072eb _GSEventRunModal + 139
25  UIKit                               0x32688845 _UIApplicationMain + 1137
26  MyApp                         0x00083fff main (main.m:4)

Thread 1:
0   libsystem_kernel.dylib              0x3a79d838 _kevent64 + 24
1   libdispatch.dylib                   0x3a6e6623 _dispatch_mgr_thread + 39

Thread 2:
0   libsystem_kernel.dylib              0x3a79da84 _mach_msg_trap + 20
1   CoreFoundation                      0x2fe6a559 __CFRunLoopServiceMachPort + 157
2   CoreFoundation                      0x2fe68c79 __CFRunLoopRun + 793
3   CoreFoundation                      0x2fdd3471 _CFRunLoopRunSpecific + 525
4   CoreFoundation                      0x2fdd3253 _CFRunLoopRunInMode + 107
5   WebCore                             0x37d9a0c5 RunWebThread(void*) + 421
6   libsystem_pthread.dylib             0x3a816c5d _pthread_body + 141
7   libsystem_pthread.dylib             0x3a816bcf __pthread_start + 103

Thread 3:
0   libsystem_kernel.dylib              0x3a79da84 _mach_msg_trap + 20
1   CoreFoundation                      0x2fe6a559 __CFRunLoopServiceMachPort + 157
2   CoreFoundation                      0x2fe68c79 __CFRunLoopRun + 793
3   CoreFoundation                      0x2fdd3471 _CFRunLoopRunSpecific + 525
4   CoreFoundation                      0x2fe170db _CFRunLoopRun + 99
5   CoreMotion                          0x3048b369 _CLSF_thorntonUpdate_6x6 + 57225
6   libsystem_pthread.dylib             0x3a816c5d _pthread_body + 141
7   libsystem_pthread.dylib             0x3a816bcf __pthread_start + 103

Thread 4:
0   libsystem_kernel.dylib              0x3a7b0c7c ___workq_kernreturn + 8

Thread 5:
0   libsystem_kernel.dylib              0x3a7b0c7c ___workq_kernreturn + 8

Thread 6:
0   libsystem_kernel.dylib              0x3a7b0c7c ___workq_kernreturn + 8

Thread 0 crashed with ARM Thread State:
    r0: 0x00000000     r1: 0x2fdd013d     r2: 0x00000000     r3: 0x00000304 
    r4: 0x00000000     r5: 0x00000004     r6: 0x00000000     r7: 0x004bb994 
    r8: 0x1752fd80     r9: 0x176e45a8    r10: 0x2ff063d0    r11: 0x3a9aa5c4 
    ip: 0x2fdd53c9     sp: 0x004bb98c     lr: 0x2fdccb6c     pc: 0x2fdd01be 
  cpsr: 0x60000030 

Binary Images:
   0x81000 -   0x202fff + MyApp armv7s  <fc1bc90151cf30da9de8889a1115ae51> /Users/USER/MyApp.app/MyApp
0x2eb73000 - 0x2eb8efff  libJapaneseConverter.dylib armv7s  <f248c9d2ab0c3a2c96b4afbb5f30e6f1> /System/Library/CoreServices/Encodings/libJapaneseConverter.dylib
0x2ed2f000 - 0x2ee30fff  AVFoundation armv7s  <759b362f09e53f37a2ec82372a95d1de> /System/Library/Frameworks/AVFoundation.framework/AVFoundation
0x2ee31000 - 0x2ee59fff  libAVFAudio.dylib armv7s  <0925efab4dd338e382aa5b10cdbed33f> /System/Library/Frameworks/AVFoundation.framework/libAVFAudio.dylib
0x2ee5a000 - 0x2ee5afff  Accelerate armv7s  <9340338f3cdf347abe4a88c2f59b5b12> /System/Library/Frameworks/Accelerate.framework/Accelerate
0x2ee64000 - 0x2f031fff  vImage armv7s  <479b5c4701833284ab587a1d2fdb5627> /System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/vImage
0x2f032000 - 0x2f114fff  libBLAS.dylib armv7s  <da4fa367557d3028b02458e2cdf6d84d> /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libBLAS.dylib
0x2f115000 - 0x2f3d0fff  libLAPACK.dylib armv7s  <066ea8372dd23f6d89011f9a4a872d6f> /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libLAPACK.dylib
0x2f3d1000 - 0x2f43ffff  libvDSP.dylib armv7s  <a5dcfe68199839b989c7be120c14ccb4> /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libvDSP.dylib
0x2f440000 - 0x2f452fff  libvMisc.dylib armv7s  <ea636bbda5ee33119a4e731aed02fa31> /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libvMisc.dylib
0x2f453000 - 0x2f453fff  vecLib armv7s  <663aefa25bc5367baa72ca144ac26d18> /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/vecLib
0x2f454000 - 0x2f473fff  Accounts armv7s  <811f7e5dcd353c57af6d6de859848774> /System/Library/Frameworks/Accounts.framework/Accounts
0x2f474000 - 0x2f474fff  AdSupport armv7s  <fa30d96d0a333568826efd5aad83097a> /System/Library/Frameworks/AdSupport.framework/AdSupport
0x2f475000 - 0x2f4dafff  AddressBook armv7s  <cc733c2c249e3161a9af19a44aeb1577> /System/Library/Frameworks/AddressBook.framework/AddressBook
0x2f4db000 - 0x2f5ecfff  AddressBookUI armv7s  <8f681556d73d3ee5b9bfead2a124927c> /System/Library/Frameworks/AddressBookUI.framework/AddressBookUI
0x2f5ed000 - 0x2f5fefff  AssetsLibrary armv7s  <4c426c7f5e3930f0bd01d3e1f17f0392> /System/Library/Frameworks/AssetsLibrary.framework/AssetsLibrary
0x2f743000 - 0x2fa5ffff  AudioToolbox armv7s  <f49f28790aa036c08e5573071a7e2870> /System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
0x2fa60000 - 0x2fb65fff  CFNetwork armv7s  <36562cff956f38a09956da9218198ccf> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
0x2fb66000 - 0x2fbc1fff  CoreAudio armv7s  <34f47ad0c4d530249298888a1217316f> /System/Library/Frameworks/CoreAudio.framework/CoreAudio
0x2fbc2000 - 0x2fbd8fff  CoreBluetooth armv7s  <0211d5169d0d3838a9cbb9dd5086a312> /System/Library/Frameworks/CoreBluetooth.framework/CoreBluetooth
0x2fbd9000 - 0x2fdcafff  CoreData armv7s  <4ed490c5fd693fefac89d75a47eab553> /System/Library/Frameworks/CoreData.framework/CoreData
0x2fdcb000 - 0x2ff0efff  CoreFoundation armv7s  <37c6b3b7abca3774bec8fecf79f07013> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x2ff0f000 - 0x30033fff  CoreGraphics armv7s  <e13cbd4115dc3113b875de88b92744f8> /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
0x30035000 - 0x30070fff  libCGFreetype.A.dylib armv7s  <4be02e4373903a7d8295e4e0859326ab> 

(too long for SO to post the rest but I can add it in a comment if anyone thinks it could be helpful)

like image 415
SAHM Avatar asked Nov 04 '13 17:11

SAHM


1 Answers

productIdentifier is nil as @rmaddy suggests in the comments. Other developers are reporting this issue on the MKStoreKit Github issues https://github.com/MugunthKumar/MKStoreKit/pull/176

The suggested fix is here: https://github.com/dfabulich/MKStoreKit/commit/4b8adb442f1d7b7a9541feab5e319969369d3f95 by Dan Fabulich (not me).

In MKStoreManager.m -(void) provideContent: (NSString*) productIdentifier add a nil check at the top:

if (!productIdentifier) {
  NSLog(@"productIdentifier is nil; Apple bug?");
  return;
}
like image 116
Nate Murray Avatar answered Oct 21 '22 00:10

Nate Murray