Benny
Benny

Reputation: 5092

Core Data causing crash on iPhone 3

I'm getting a strange error with core data. Sometimes, but not all the time my app will crash when I try to access a core data object.

It happens regularly on iPhone 3's and only sometimes on iPhone 4's. I looked at my device log and narrowed it down to an issue with core data. The line the logs refer to is below, tripInstructor is a core data object, its a property of the AppManager class. Not sure if this makes a big difference but I do declare the property as being "nonatomic, retain".

Thanks for any advice

[self.supervisorLbl setText:[AppManager sharedAppManager].tripInstructor.name];


Date/Time:       2011-06-12 20:55:24.865 +1000
OS Version:      iPhone OS 4.3.3 (8J2)
Report Version:  104

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x00000000, 0x00000000 Crashed Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x33e8da1c pthread_kill + 8 1 libsystem_c.dylib 0x35e5b3b4 pthread_kill + 52 2 libsystem_c.dylib 0x35e53bf8 abort + 72 3 libstdc++.6.dylib 0x33508a64 __gnu_cxx::__verbose_terminate_handler() + 376 4 libobjc.A.dylib 0x33f1106c _objc_terminate + 104 5 libstdc++.6.dylib 0x33506e36 _cxxabiv1::_terminate(void (*)()) + 46 6 libstdc++.6.dylib 0x33506e8a std::terminate() + 10 7 libstdc++.6.dylib 0x33506efe __cxa_rethrow + 62 8 libobjc.A.dylib 0x33f10fd8 objc_exception_rethrow + 4 9 CoreData 0x35624f66 _PFFaultHandlerLookupRow + 1450 10 CoreData 0x356799ba -[NSFaultHandler fulfillFault:withContext:] + 14 11 CoreData 0x35678782 _PF_FulfillDeferredFault + 354 12 CoreData 0x35623f18 _sharedIMPL_pvfk_core + 52 13 CoreData 0x35626b68 _pvfk_5 + 4 14 eLogger 0x0000e346 -[VicLogVC viewWillAppear:] (VicLogVC.m:207) 15 UIKit 0x3636bf14 -[UINavigationController _startTransition:fromViewController:toViewController:] + 604 16 UIKit 0x3636bc3c -[UINavigationController _startDeferredTransitionIfNeeded] + 176 17 UIKit 0x3635dd56 -[UINavigationController pushViewController:transition:forceImmediate:] + 634 18 UIKit 0x3635dacc -[UINavigationController pushViewController:animated:] + 28 19 eLogger 0x00025332 -[TripScreenVC _populateAndDisplayVicLog] (TripScreenVC.m:221) 20 eLogger 0x00025492 -[TripScreenVC _determineLogScreen] (TripScreenVC.m:258) 21 eLogger 0x000255d4 -[TripScreenVC buttonPressed:] (TripScreenVC.m:307) 22 CoreFoundation 0x30d4356a -[NSObject(NSObject) performSelector:withObject:withObject:] + 18 23 UIKit 0x36343ec2 -[UIApplication sendAction:to:from:forEvent:] + 78 24 UIKit 0x36343e62 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26 25 UIKit 0x36343e34 -[UIControl sendAction:to:forEvent:] + 32 26 UIKit 0x36343b86 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 350 27 UIKit 0x3634441c -[UIControl touchesEnded:withEvent:] + 336 28 UIKit 0x36342bee -[UIWindow _sendTouchesForEvent:] + 362 29 UIKit 0x36342568 -[UIWindow sendEvent:] + 256 30 UIKit 0x3632b30c -[UIApplication sendEvent:] + 292 31 UIKit 0x3632ac4c _UIApplicationHandleEvent + 5084 32 GraphicsServices 0x34e2be70 PurpleEventCallback + 660 33 CoreFoundation 0x30daaa90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 20 34 CoreFoundation 0x30dac838 __CFRunLoopDoSource1 + 160 35 CoreFoundation 0x30dad606 __CFRunLoopRun + 514 36 CoreFoundation 0x30d3debc CFRunLoopRunSpecific + 224 37 CoreFoundation 0x30d3ddc4 CFRunLoopRunInMode + 52 38 GraphicsServices 0x34e2b418 GSEventRunModal + 108 39 GraphicsServices 0x34e2b4c4 GSEventRun + 56 40 UIKit 0x36355d62 -[UIApplication _run] + 398 41 UIKit 0x36353800 UIApplicationMain + 664 42 eLogger 0x00002ff8 main (main.m:14) 43 eLogger 0x00002fa0 start + 32

Upvotes: 1

Views: 607

Answers (1)

ImHuntingWabbits
ImHuntingWabbits

Reputation: 3827

You are likely holding on to an invalid reference to a managed object, it looks like it was turned into a fault by the managed object context, perhaps after calling -save: or -reset on the context.

If you deleted an object from your store, and still held a reference to the managed object in the ivar then that could be the cause of this error. The object will be deleted by CoreData and turned into a fault when -save: is called (at which point you should nil and reset your ivars). But, when you try to fault the object (by accessing one or more of it's properties) it won't be found in the store because you deleted it.

Upvotes: 1

Related Questions