Segmentation Fault when calling NSRegularExpression:matchesInString - ios

I have a crash in my (deployed) iOS-App while starting. It looks like it happens in some lib-functions and I'm not sure how this could be. The console output says
Oct 15 17:05:42 iPadMiniR MyApp[260] <Warning>: INFO: downloading package data 5 of 5...
Oct 15 17:05:42 iPadMiniR ReportCrash[261] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)
Oct 15 17:05:42 iPadMiniR ReportCrash[261] <Notice>: ReportCrash acting against PID 260
Oct 15 17:05:42 iPadMiniR diagnosticd[150] <Error>: error evaluating process info - pid: 260, punique: 260
Oct 15 17:05:42 iPadMiniR ReportCrash[261] <Notice>: Formulating crash report for process myApp[260]
so I analyzed the Crash Report:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000058
Triggered by Thread: 4
[...]
Thread 4 name: Dispatch queue: com.apple.root.default-qos
Thread 4 Crashed:
0 libobjc.A.dylib 0x00000001946d3bd0 objc_msgSend + 16
1 Foundation 0x0000000184ac884c -[NSSimpleRegularExpressionCheckingResult initWithRanges:count:regularExpression:] + 176
2 Foundation 0x0000000184aaf2a4 -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 1340
3 Foundation 0x0000000184ac8720 -[NSRegularExpression(NSMatching) matchesInString:options:range:] + 152
4 myApp [...]
I know what a Segfault is but I don't understand, why it can happen in a Library function. I already searched in Apple's developer documentation of NSRegularExpression (under enumerateMatchesInString:options:range:usingBlock: and matchesInString:options:range:) and googled for NSSimpleRegularExpressionCheckingResult, but I didn't find a thing that helps. In similar questions here on StackOverflow, the SIGSEGV occurs not in library functions but in the user's code.
My question is: How could a Segfault in this context occur? Doesn't the objective-C-Library-Functions check pointers? Or could it be that a pointer become dangled between the check and the usage (weak pointers, but I don't have any of them)?
I'm pretty new to iOS development, so thanks for any help :)
I use XCode 6.0.1 and iOS 8.0.2.

Related

Application only crashes on start when run on TestFlight

Currently I have an iOS app which I plan to release for beta testing. My problem is that the app will not run as after 2 seconds or so after the app has shown the GameScene.swift SKScene, it crashes and it keeps on repeating.
I have compiled the app via Xcode 7.3 in both Release and Debug configurations. I have analysed the project, cleaned it, uninstalled it, reinstalled it, restored my device etc. But nothing changes. This unexpected crash only happens when the app is run via TestFlight. I will attach below the log from the crashes. I have tried to symbolicate the crash but it just shows up the original log file.
Incident Identifier: 408B1212-4AE8-42E2-905F-D4567D5030AD
CrashReporter Key: 4c7013cab29b9011557c3005550950488452cc04
Hardware Model: xxx
Process: Number Tap [2226]
Path: /private/var/containers/Bundle/Application/69833BAF-AD19-4FAF-BB95-E766A493D525/Number Tap.app/Number Tap
Identifier: com.flatboxstudio.numbertap
Version: 2 (1.0.1)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2016-03-29 18:44:31.31 -0700
Launch Time: 2016-03-29 18:44:31.31 -0700
OS Version: iOS 9.3 (13E233)
Report Version: 105
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000100046724
Triggered by Thread: 0
Filtered syslog:
None found
Breadcrumb Trail: (reverse chronological seconds)
0 GC Framework: startAuthenticationForExistingPrimaryPlayer
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 Number Tap 0x0000000100046724 0x10000c000 + 239396
1 libdispatch.dylib 0x000000018200d4bc 0x18200c000 + 5308
2 libdispatch.dylib 0x000000018200d47c 0x18200c000 + 5244
3 libdispatch.dylib 0x0000000182012b84 0x18200c000 + 27524
4 CoreFoundation 0x0000000182578dd8 0x182498000 + 921048
5 CoreFoundation 0x0000000182576c40 0x182498000 + 912448
6 CoreFoundation 0x00000001824a0d10 0x182498000 + 36112
7 GraphicsServices 0x0000000183d88088 0x183d7c000 + 49288
8 UIKit 0x000000018776df70 0x1876f0000 + 515952
9 Number Tap 0x0000000100046bdc 0x10000c000 + 240604
10 libdyld.dylib 0x000000018203e8b8 0x18203c000 + 10424
Activity ID: 0x0000000000043e33
Activity Name: starting resolver activity
Activity Image Path: /usr/lib/system/libsystem_network.dylib
Activity Image UUID: A1D92752-ABF1-3834-9EBB-FE35E00EB642
Activity Offset: 0x0003333c
Activity Running Time: 0.468516 sec
Trace Messages (reverse chronological seconds):
0.292098 GameCenterFoundation 0x000000019066a20c authenticateWithCompletionHandler:Username and Password passed in. GKDaemonProxy to authenticate player
0.296164 CFNetwork 0x0000000204da9da8 Format not found
0.300431 CFNetwork 0x0000000204da9da8 Format not found
0.301584 CFNetwork 0x0000000204da9da8 Format not found
0.301623 CFNetwork 0x0000000182c493a8 TCP Conn 0x146553ea0 started
0.305076 CFNetwork 0x0000000182ca3ce8 Creating default cookie storage with default identifier
0.305077 CFNetwork 0x0000000182ca3cb4 Faulting in CFHTTPCookieStorage singleton
0.305077 CFNetwork 0x0000000182cf5e44 Faulting in NSHTTPCookieStorage singleton
I removed some of the log as I felt it may be unimportant. I have read apples guide on resolving this but still not resolved.I will be truly grateful if anybody could help me out. If you need any extra code, logs or information don't hesitate to ask. (The whole log was quite long so I cropped some information out.)

iOS 8 notification action: "Access to item attempted while keychain is locked" error when accessing keychain in "didFinishLaunchingWithOptions"

I am observing a keychain error in the device console thrown by SecItemCopyMatching when acting on an iOS 8 push notification on a locked phone. The detailed repro steps are as follows:
Uninstall all previous versions of the app. Build an Appstore version of the app onto device. Force quit the app.
Increment build number, and build a newer version onto device. This simulates an app update flow. Force quit the app (In real life, the app might get killed by the OS due to memory pressure. Force quitting simulates this behavior).
Send a push notification to the app when the phone is locked.
With the phone locked, swipe left to see the action buttons and press one of the action buttons.
App gets woken up, didFinishLaunchingWithOptions gets called, which tries to access a keychain item. While running SecItemCopyMatching, an error Access to item attempted while keychain is locked shows up in the device console.
The complete error log is shown below. The last line gives the app specific error message.
ReportCrash[32481] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)
ReportCrash[32481] <Notice>: ReportCrash acting against PID 31423
diagnosticd[32258] <Error>: error evaluating process info - pid: 31423, punique: 131317
ReportCrash[32481] <Notice>: Formulating crash report for process cfprefsd[31423]
com.apple.xpc.launchd[1] (com.apple.cfprefsd.xpc.daemon[31423]) <Notice>: Service exited due to signal: Bus error: 10
My App[32480] <Error>: assertion failed: 12F70: libxpc.dylib + 71768 [B870B51D-AA85-3686-A7D9-ACD48C5FE153]: 0x7d
Unknown[32480] <Error>:
ReportCrash[32481] <Notice>: Saved report to /Library/Logs/CrashReporter/cfprefsd_2015-07-02-150139_Xianjing-Hus-iPhone.ips
securityd[32279] <Error>: s3dl_query_row decode genp,rowid=8099 failed (-25308): The operation couldn’t be completed. (OSStatus error -25308 - ks_crypt: e00002e2 failed to unwrap item (class 6, bag: 0) Access to item attempted while keychain is locked.)
securityd[32279] <Error>: securityd_xpc_dictionary_handler Okta Verify[32480] copy_matching The operation couldn’t be completed. (OSStatus error -25308 - ks_crypt: e00002e2 failed to unwrap item (class 6, bag: 0) Access to item attempted while keychain is locked.)
My App[32480] <Error>: SecOSStatusWith error:[-25308] The operation couldn’t be completed. (OSStatus error -25308 - Remote error : The operation couldn't be completed. (OSStatus error -25308 - ks_crypt: e00002e2 failed to unwrap item (class 6, bag: 0) Access to item attempted while keychain is locked.))
A few things:
The keychain item's accessibility is set to kSecAttrAccessibleAlways.
As can be seen in the device log above, there is always a cfprefsd process crash prior to the issue.
This issue only occurs on Appstore builds, not on debug builds.
This issue only occurs when trying to act on notification on a locked phone.
This issue only occurs when the app is newly updated, as described in the repro steps above.
Because I force quit the app, when the push notification arrives and I pressed on the action button, my app will be launched in background. didFinishLaunchingWithOptions gets called, and inside this delegate method, I am doing my keychain access which throws the error.
Has anyone seen a similar error and if so, how did you resolve the issue? Any help is appreciated.
Update: Attaching cfprefsd crash log
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: unknown at 0x00000001007d4000
Triggered by Thread: 2
Thread 0 name: Dispatch queue: com.apple.libdispatch-manager
Thread 0:
0 libsystem_kernel.dylib 0x0000000197d88c24 kevent64 + 8
1 libdispatch.dylib 0x0000000197c6de6c _dispatch_mgr_invoke + 272
2 libdispatch.dylib 0x0000000197c5f998 _dispatch_mgr_thread + 48
Thread 1 name: Dispatch queue: com.apple.root.default-qos.overcommit
Thread 1:
0 libsystem_kernel.dylib 0x0000000197da3984 __sigsuspend_nocancel + 8
1 libdispatch.dylib 0x0000000197c6921c _dispatch_sigsuspend + 24
2 libdispatch.dylib 0x0000000197c69200 _dispatch_sig_thread + 44
Thread 2 name: Dispatch queue: src
Thread 2 Crashed:
0 libsystem_platform.dylib 0x0000000197e35300 _platform_memmove + 176
1 libxpc.dylib 0x0000000197e6567c xpc_data_create + 84
2 CoreFoundation 0x0000000185d5a9b8 -[CFPDSource acceptMessage:] + 1956
3 CoreFoundation 0x0000000185dc0da8 __handle_synchronize_message_block_invoke103 + 172
4 CoreFoundation 0x0000000185d57c58 __88+[CFPDSource withSourceForDomain:inContainer:user:byHost:managed:synchronously:perform:]_block_invoke_2 + 24
5 CoreFoundation 0x0000000185d5955c __25-[CFPDSource lockedSync:]_block_invoke + 44
6 libdispatch.dylib 0x0000000197c5d950 _dispatch_client_callout + 12
7 libdispatch.dylib 0x0000000197c671e0 _dispatch_barrier_sync_f_invoke + 72
8 CoreFoundation 0x0000000185d59520 -[CFPDSource lockedSync:] + 80
9 CoreFoundation 0x0000000185d57c0c __88+[CFPDSource withSourceForDomain:inContainer:user:byHost:managed:synchronously:perform:]_block_invoke + 504
10 libdispatch.dylib 0x0000000197c5d950 _dispatch_client_callout + 12
11 libdispatch.dylib 0x0000000197c671e0 _dispatch_barrier_sync_f_invoke + 72
12 CoreFoundation 0x0000000185d576fc +[CFPDSource withSourceForDomain:inContainer:user:byHost:managed:synchronously:perform:] + 364
13 CoreFoundation 0x0000000185dc0508 handle_message + 1312
14 CoreFoundation 0x0000000185dc081c __handle_multi_message_block_invoke_2 + 124
15 libxpc.dylib 0x0000000197e657c0 xpc_array_apply + 76
16 CoreFoundation 0x0000000185dc05f8 handle_message + 1552
17 CoreFoundation 0x0000000185dbffd4 ____CFXPreferencesDaemon_main_block_invoke_5 + 132
18 libxpc.dylib 0x0000000197e64cc8 _xpc_connection_call_event_handler + 64
19 libxpc.dylib 0x0000000197e62bcc _xpc_connection_mach_event + 2156
20 libdispatch.dylib 0x0000000197c5da24 _dispatch_client_callout4 + 12
21 libdispatch.dylib 0x0000000197c6113c _dispatch_mach_msg_invoke + 488
22 libdispatch.dylib 0x0000000197c682d0 _dispatch_queue_drain + 2004
23 libdispatch.dylib 0x0000000197c60664 _dispatch_mach_invoke + 132
24 libdispatch.dylib 0x0000000197c6a314 _dispatch_root_queue_drain + 716
25 libdispatch.dylib 0x0000000197c6bc48 _dispatch_worker_thread3 + 104
26 libsystem_pthread.dylib 0x0000000197e3d228 _pthread_wqthread + 812
27 libsystem_pthread.dylib 0x0000000197e3ceec start_wqthread + 0
This error is definitely caused by trying to access an item that is kSecAttrAccessibleWhenUnlocked while device is still locked. You can tell this just by looking at the following line of the log you've provided:
securityd[32279] <Error>: securityd_xpc_dictionary_handler Okta Verify[32480] copy_matching The operation couldn’t be completed. (OSStatus error -25308 - ks_crypt: e00002e2 failed to unwrap item (class 6, bag: 0) Access to item attempted while keychain is locked.)
Class 6 is kSecAttrAccessibleWhenUnlocked (and kSecAttrAccessibleAlways is class 8) – see slide 15 of this deck for more details – so the behaviour you're seeing is expected.
The real question now is why the item ends up as kSecAttrAccessibleWhenUnlocked while you think it's kSecAttrAccessibleAlways. It is hard to tell without seeing more code and/or having more information, but here are few things to consider:
Keychain items are not removed when app is uninstalled – they do survive app reinstallation/upgrade. So if an earlier version of the app created an item as kSecAttrAccessibleWhenUnlocked it could have just carried on. Try removing the item and creating it again (and check return values of SecItemDelete() and SecItemAdd() to be sure it's done).
Double check that kSecAttrAccessibleAlways is passed to SecItemAdd() so that iOS doesn't apply any defaults on its own.
Note that accessibility class must be passed when creating item (i.e. to SecItemAdd()) and not when retrieving it (i.e. not to SecItemCopyMatching()). This is kind of obvious but it never hurts to reiterate.
If none of the above helps please post relevant code showing how the item is created and then how it's read.
Access to the keychain is blocked when you have a password on your device and the device is locked. So you can't do any actions with the keychain from lock screen if you have a password.

KERN_INVALID_ADDRESS at 0x0000000000000000

I have developed an iPad application using Xcode 6.3.2.
I submitted my application to the App Store for review where it was reject due to crash.Following is the crash report from iTunes.
Incident Identifier: 88DD7F94-3382-4241-A0D7-C3E7F6D20737
CrashReporter Key: 9881ae0cc3b3fbfccfd0ce1496d2fa08fec08782
Hardware Model: xxx
Path: /private/var/mobile/Containers/Bundle/Application/FDBBD67F-0EF7-43FB-80CB-8308A10A2D29/Vehicle Visuals.app/Vehicle Visuals
Identifier: com.vehiclevisuals.Vehicle-Visuals
Version: 2.0.0 (1.1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2015-06-12 12:33:57.988 -0700
Launch Time: 2015-06-12 12:22:14.581 -0700
OS Version: iOS 8.3 (12F69)
Report Version: 105
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000195da7bdc 0x195d8c000 + 113628
1 QuartzCore 0x00000001889fdc2c 0x1889ec000 + 72748
2 Vehicle Visuals 0x0000000100126828 0x1000ec000 + 239656
3 Vehicle Visuals 0x0000000100101e80 0x1000ec000 + 89728
4 UIKit 0x0000000189118778 0x1890a4000 + 477048
5 UIKit 0x0000000189116750 0x1890a4000 + 468816
6 UIKit 0x0000000189112000 0x1890a4000 + 450560
7 UIKit 0x00000001890b175c 0x1890a4000 + 55132
8 QuartzCore 0x00000001889f9e18 0x1889ec000 + 56856
9 QuartzCore 0x00000001889f4880 0x1889ec000 + 34944
10 QuartzCore 0x00000001889f4724 0x1889ec000 + 34596
11 QuartzCore 0x00000001889f3eb8 0x1889ec000 + 32440
12 QuartzCore 0x00000001889f3c38 0x1889ec000 + 31800
13 UIKit 0x0000000189137f8c 0x1890a4000 + 606092
14 UIKit 0x0000000189137ef0 0x1890a4000 + 605936
15 CoreFoundation 0x000000018462c2a0 0x18454c000 + 918176
16 CoreFoundation 0x000000018462922c 0x18454c000 + 905772
17 CoreFoundation 0x000000018462955c 0x18454c000 + 906588
18 CoreFoundation 0x00000001845552d0 0x18454c000 + 37584
19 GraphicsServices 0x000000018dc436f8 0x18dc38000 + 46840
20 UIKit 0x000000018911afa8 0x1890a4000 + 487336
21 Vehicle Visuals 0x000000010013a1cc 0x1000ec000 + 319948
22 libdyld.dylib 0x0000000196412a04 0x196410000 + 10756
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
As per the report it crashes on OS Version : iOS 8.3 (12F69).
I tested my app on the all simulators(iPad Air, iPad 2, iPad Retina) with same config(iOS version 8.3 (12F69)) and also tested it on my device (iPad mini) with iOS version 8.3 (12F69), but didn't crashed on my side.
But it crashes on my friend's iPad Air with same iOS version (it gives the same crash report with different invalid address as below)
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype:
KERN_INVALID_ADDRESS at 0x0000000000000020 Triggered by Thread: 0
I don't have the iPad Air so that I could debug using the device.
I also tried to Symbolicated crash report using following command.
xcrun atos -o VehicleVisuals 0x0000000000000020
But it just gives me following hex code.
0x00000020 (in VehicleVisuals)
I following Link for symbolication.
I'm just not being able to recognise where actually is the crash issue.
Please can anybody help me out?
EXC_BAD_ACCESS usually happens because you are sending an Obj-C message to an invalid memory address, what means that you probably are trying to access some deallocated object.
It may be working on other devices because this object is not being released at the same time.
I recently had a similar crash that happened because there was a timer not being invalidated on dealloc, and when the target method was called, that object did no longer exist.
You could try to enable NSZombie objects and see if you find which object is being deallocated. In xCode 6, you can enable them in Product > Scheme > Edit scheme > Diagnostics > Enable Zombie Objects.
Also, there are lots of these kind of errors that NSZombieEnabled can't detect. Unfortunately there is nothing magical to solve it. The second option would be to run your app with instruments (memory leaks specifically) and see if you can get something. If this doesn't work you will have to review your code and check that there are no possibilities that you are trying to access a deallocated object. Hope it helps.
Good luck!

App Review has rejected my app: EXC_CRASH (SIGABRT)

We testing my app with iPhone 6s/iPhone 6/iPhone 5, no bugs and crash report, but when we submit to iTunesConnect, the App Review team has rejected my app, they said this app crashed on launch.
We can not reproduce this crash, I have no idea what the crash log below means. I would be really happy if anybody could explain me what this crash log could relate to and how I could solve it. Many many thanks to all those who are willing to help others.
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Filtered syslog:
2015-02-05 06:00:28.268 chuanBang[993]: <Error> assertion failed: 12B411: libxpc.dylib + 51955 [04694BEB-256F-3132-A00F-0C82B79BC689]: 0x7d
2015-02-05 06:00:29.105 chuanBang[993]: <Error> SecTrustEvaluate [leaf AnchorTrusted]
2015-02-05 06:00:29.517 chuanBang[993]: <Error> CoreLocation: Could not get ideal gyro update interval, assuming 0.005000 s
2015-02-05 06:00:30.615 chuanBang[993]: <Warning> Attempting to badge the application icon but haven't received permission from the user to badge the application
2015-02-05 06:00:30.619 chuanBang[993]: <Warning> 请求失败了
2015-02-05 06:00:30.623 chuanBang[993]: <Warning> 请求失败了
Last Exception Backtrace:
(0x26988d62 0x342bfc72 0x26988ca8 0x2c3084 0x3499b096 0x349a0d0e 0x348c0934 0x33acdbb8 0x33ae4e30 0x33ae48b4 0x342bfdba 0x2689aa18 0x2689a78e 0x2dd4c04c 0x29e8c97c 0x1b2a1a 0x3485baaa)
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x34920dfc 0x3490c000 + 85500
1 libsystem_pthread.dylib 0x349a0d0e 0x3499d000 + 15630
2 libsystem_c.dylib 0x348c0934 0x34877000 + 301364
3 libc++abi.dylib 0x33acdbb8 0x33acd000 + 3000
4 libc++abi.dylib 0x33ae4e30 0x33acd000 + 97840
5 libc++abi.dylib 0x33ae4ee6 0x33acd000 + 98022
6 libc++abi.dylib 0x33ae4b9c 0x33acd000 + 97180
7 libc++abi.dylib 0x33ae4e44 0x33acd000 + 97860
8 libc++abi.dylib 0x33ae48b4 0x33acd000 + 96436
9 libobjc.A.dylib 0x342bfdba 0x342b9000 + 28090
10 CoreFoundation 0x2689aa18 0x26881000 + 104984
11 CoreFoundation 0x2689a78e 0x26881000 + 104334
12 GraphicsServices 0x2dd4c04c 0x2dd43000 + 36940
13 UIKit 0x29e8c97c 0x29e1e000 + 452988
14 chuanBang 0x001b2a1a 0xad000 + 1071642
15 libdyld.dylib 0x3485baac 0x3485a000 + 6828
The crash log itself is not useful. I suggest integrating a crash reporting SDK into your app and when a crash does happen, it will give you a lot more info than you're currently getting.
Some crash reporters to look over:
Crashlytics
HockeyApp
Once you have one of these integrated into your app, submit the app again to Apple (If you cannot reproduce the error) and if it crashes their side, you'll have a much better idea where the issue is.
I think whenever you are testing your app at that time you always allow for Notification permission Popup & Location service permission popup.
Please try by click "Don't allow" when these popup are show.

com.apple.gamed is crashing when deleting a game [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an iOS app that consistently crashes when you try to delete a GKTurnBasedMatch using
[match removeWithCompletionHandler:^(NSError *error){}];
When the completion handler is called, error is nil, meaning that it successfully deleted the match. The match does get deleted (it never re-appears), but at the same time, gamed (the background daemon written by apple that communicates with GameCenter servers) crashes.
Here is what I see in the Console when I delete a game:
Jan 19 20:47:22 Ben-L-iPhone gamed[2233] <Error>: *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0xd000000000b4002a <x-coredata://C0390AE6-6CD0-4A7C-B080-B7649175419A/TurnBasedSession/p45>''
*** First throw call stack:
(0x185ce309c 0x191c61d78 0x1859eb7ac 0x1859fc50c 0x1859fc47c 0x185a7475c 0x185a79034 0x185a797f4 0x185a7a474 0x1922303e0 0x192235d88 0x185a6f3e4 0x185a7a104 0x1859fdbd0 0x100099284 0x185a71b6c 0x1922303e0 0x192235f2c 0x185a71d00 0x10009ce08 0x1000ba8a4 0x192230420 0x1922303e0 0x192235930 0x1922303e0 0x1922373fc 0x192237638 0x1923c5918 0x1923c57a8)
Jan 19 20:47:22 Ben-L-iPhone ReportCrash[2509] <Notice>: ReportCrash acting against PID 2233
Jan 19 20:47:22 Ben-L-iPhone ReportCrash[2509] <Notice>: Formulating crash report for process gamed[2233]
Jan 19 20:47:22 Ben-L-iPhone com.apple.launchd[1] (com.apple.gamed[2233]) <Warning>: (com.apple.gamed) Job appears to have crashed: Abort trap: 6
Jan 19 20:47:22 Ben-L-iPhone ReportCrash[2509] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/gamed_2014-01-19-204722_Ben-L-iPhone.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
Any ideas what could trigger this? I've searched the Apple Dev forums and Google and haven't been able to find someone with a similar problem.
Crash Report Logged
Incident Identifier: C201F189-7311-49E5-96F4-890A65FAA19A
CrashReporter Key: 0b745533f4a51b30bf9654557be6c063d06f1ccc
Hardware Model: iPhone6,1
Process: gamed [2233]
Path: /usr/libexec/gamed
Identifier: gamed
Version: ???
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2014-01-19 20:47:22.522 -0600
OS Version: iOS 7.0.4 (11B554a)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 11
Last Exception Backtrace:
0 CoreFoundation 0x185ce309c __exceptionPreprocess + 132
1 libobjc.A.dylib 0x191c61d78 objc_exception_throw + 60
2 CoreData 0x1859eb7ac _PFFaultHandlerLookupRow + 1900
3 CoreData 0x1859fc50c -[NSManagedObject(_NSInternalMethods) _newPropertiesForRetainedTypes:andCopiedTypes:preserveFaults:] + 108
4 CoreData 0x1859fc47c -[NSManagedObject(_NSInternalMethods) _newAllPropertiesWithRelationshipFaultsIntact__] + 108
5 CoreData 0x185a7475c -[NSManagedObjectContext(_NSInternalAdditions) _committedSnapshotForObject:] + 72
6 CoreData 0x185a79034 -[NSManagedObjectContext(_NestedContextSupport) _copyChildObject:toParentObject:fromChildContext:] + 144
7 CoreData 0x185a797f4 -[NSManagedObjectContext(_NestedContextSupport) _parentProcessSaveRequest:inContext:error:] + 1092
8 CoreData 0x185a7a474 __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke + 660
9 libdispatch.dylib 0x1922303e0 _dispatch_client_callout + 16
10 libdispatch.dylib 0x192235d88 _dispatch_barrier_sync_f_slow + 352
11 CoreData 0x185a6f3e4 _perform + 124
12 CoreData 0x185a7a104 -[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:] + 184
13 CoreData 0x1859fdbd0 -[NSManagedObjectContext save:] + 840
14 gamed 0x100099284 0x100048000 + 332420
15 CoreData 0x185a71b6c developerSubmittedBlockToNSManagedObjectContextPerform + 100
16 libdispatch.dylib 0x1922303e0 _dispatch_client_callout + 16
17 libdispatch.dylib 0x192235f2c _dispatch_barrier_sync_f_invoke + 48
18 CoreData 0x185a71d00 -[NSManagedObjectContext performBlockAndWait:] + 132
19 gamed 0x10009ce08 0x100048000 + 347656
20 gamed 0x1000ba8a4 0x100048000 + 469156
21 libdispatch.dylib 0x192230420 _dispatch_call_block_and_release + 24
22 libdispatch.dylib 0x1922303e0 _dispatch_client_callout + 16
23 libdispatch.dylib 0x192235930 _dispatch_async_redirect_invoke + 152
24 libdispatch.dylib 0x1922303e0 _dispatch_client_callout + 16
25 libdispatch.dylib 0x1922373fc _dispatch_root_queue_drain + 400
26 libdispatch.dylib 0x192237638 _dispatch_worker_thread2 + 76
27 libsystem_pthread.dylib 0x1923c5918 _pthread_wqthread + 356
28 libsystem_pthread.dylib 0x1923c57a8 start_wqthread + 4
Additional Information
I went back and added logging around the removeMatch. This logging is from the sandbox, but it happens in production too.
Notice, the game is already in a final state (status:GKTurnBasedMatchStatusEnded) right before the match is removed.
As soon as I removed the match, I tried to start a new match. The first try results in a "The operation couldn’t be completed. (Cocoa error 4097.)", the second try nearly 2 minutes later results in a GKServerStatusCode=5000 because the player is no longer authenticated.
2014-01-19 22:23:31.436 KingChase[3432:70b] removing match <GKTurnBasedMatch 0xc50d8f0 - matchID:e0e24a77-fb5c-46a7-b843-21e8becf9735 bundleID:us.pojo.kingchase status:GKTurnBasedMatchStatusEnded message:'Game Over! kctest2 won.' creationDate:2014-01-20 04:17:31 +0000 currentParticipant:(null) participants:<GKTurnBasedParticipant 0xc4e9870 - playerID:G:1972295489 (local player) status:Done matchOutcome:Won lastTurnDate:2014-01-20 04:22:50 +0000 timeoutDate:(null)>,<GKTurnBasedParticipant 0xc439aa0 - playerID:G:1972168157 status:Done matchOutcome:Lost lastTurnDate:2014-01-20 04:23:17 +0000 timeoutDate:(null)> matchData.length:438 matchDataMaximumSize:65536 exchanges:(null)>
2014-01-19 22:23:31.441 KingChase[3432:70b] Match removed.
2014-01-19 22:23:31.442 KingChase[3432:70b] Match cleaned up.
2014-01-19 22:23:40.681 KingChase[3432:70b] Match Making failed. Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"
2014-01-19 22:25:30.053 KingChase[3432:70b] Match Making failed. Error Domain=GKErrorDomain Code=6 "The requested operation could not be completed because local player has not been authenticated." UserInfo=0xc527430 {GKServerStatusCode=5000, NSUnderlyingError=0xc5222b0 "The operation couldn’t be completed. status = 5000, missing required header: x-gk-player-id", NSLocalizedDescription=The requested operation could not be completed because local player has not been authenticated.}
The other player was able to delete the game without crashing gamed.
Updated Jan 20, 2014 - 6:32PM CDT - Further Information
I have added logging with every single interaction that I make with GameKit.
Jan 20 17:39:17 Ben-L-iPhone KingChase[3154] <Warning>: GK: [match.currentParticipant.playerID isEqualToString:localPlayer.playerID]
Jan 20 17:39:17 Ben-L-iPhone KingChase[3154] <Warning>: GK: [match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:completionHandler];
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: removing match <GKTurnBasedMatch 0x1669bdb0 - matchID:a182e163-8006-413e-a203-c93d534ac550 bundleID:us.pojo.kingchase status:GKTurnBasedMatchStatusEnded message:'Game Over! kctest1 won.' creationDate:2014-01-20 23:12:32 +0000 currentParticipant:(null) participants:<GKTurnBasedParticipant 0x166ae6f0 - playerID:G:1972168157 (local player) status:Done matchOutcome:Won lastTurnDate:2014-01-20 23:27:14 +0000 timeoutDate:(null)>,<GKTurnBasedParticipant 0x1664d260 - playerID:G:1972295489 status:Done matchOutcome:Lost lastTurnDate:2014-01-20 23:38:15 +0000 timeoutDate:(null)> matchData.length:390 matchDataMaximumSize:65536 exchanges:(null)>
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: GK: [match removeWithCompletionHandler:^(NSError *error)
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: Match removed.
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: Match cleaned up.
Jan 20 17:39:19 Ben-L-iPhone gamed[3125] <Error>: *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0xd00000000024001a <x-coredata://3A4F66E1-B95C-4692-B905-EA1398FB97CE/TurnBasedSession/p9>''
*** First throw call stack:
(0x185ce309c 0x191c61d78 0x1859eb7ac 0x1859fc50c 0x1859fc47c 0x185a7475c 0x185a79034 0x185a797f4 0x185a7a474 0x1922303e0 0x192235d88 0x185a6f3e4 0x185a7a104 0x1859fdbd0 0x10014d284 0x185a71b6c 0x1922303e0 0x192235f2c 0x185a71d00 0x100150e08 0x10016e8a4 0x192230420 0x1922303e0 0x192235930 0x1922303e0 0x1922373fc 0x192237638 0x1923c5918 0x1923c57a8)
I think this now has to do with my calling
[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:completionHandler];
after the game is already complete. I will test the hypothesis when I have time and submit the bug report to Apple.
I have figured out that this problem appears to happen when you call [match removeWithCompletionHandler:^(NSError *error)] from within the completion handler of another GameKit call.
If you look in the log above:
[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:completionHandler];
is called, and the completionHandler for that method was calling -removeWithCompletionHandler:
I solved this problem using this change:
by executing the removeWithCompletionHandler in this manner:
[match performSelector:#selector(removeWithCompletionHandler:) withObject:^(NSError *error) {} afterDelay:5.0];

Resources