We have released an app to the AppStore and after an update it crashes after trying to login. We have been heavily relying on a CoreData database in it and we think it is the reason of the crash. Nevertheless I couldn't get any valuable info from the device, just a crash log that features some thread information. Here's how it looks:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xd0000008
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x32b3e5b0 objc_msgSend + 16
1 Foundation 0x337cbd18 -[NSError dealloc] + 56
2 libobjc.A.dylib 0x32b40484 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 164
3 CoreFoundation 0x31bc843c _CFAutoreleasePoolPop + 12
4 Foundation 0x337ccf76 -[NSAutoreleasePool drain] + 118
5 CoreData 0x32f6d4ae -[NSManagedObjectContext save:] + 1206
6 ourapp 0x0012fbf8 0xba000 + 482296
7 CoreData 0x32f70bbe developerSubmittedBlockToNSManagedObjectContextPerform + 86
8 CoreData 0x32f70cee -[NSManagedObjectContext performBlockAndWait:] + 90
9 ourapp 0x0012fb4c 0xba000 + 482124
10 ourapp 0x000c4e08 0xba000 + 44552
11 ourapp 0x000cced4 0xba000 + 77524
12 ourapp 0x000db50a 0xba000 + 136458
13 ourapp 0x0014c41a 0xba000 + 599066
14 Foundation 0x33893ef2 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 14
15 Foundation 0x337d39ec -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 196
16 Foundation 0x337d3908 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 56
17 CFNetwork 0x38da65dc ___delegate_didFinishLoading_block_invoke_0 + 24
18 CFNetwork 0x38da5cc8 ___withDelegateAsync_block_invoke_0 + 52
19 CFNetwork 0x38dce130 ___performAsync_block_invoke_068 + 16
20 CoreFoundation 0x31bcb74a CFArrayApplyFunction + 174
21 CFNetwork 0x38dce58e RunloopBlockContext::perform() + 70
22 CFNetwork 0x38d3215a MultiplexerSource::perform() + 186
23 CoreFoundation 0x31c5a680 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
24 CoreFoundation 0x31c59f7a __CFRunLoopDoSources0 + 358
25 CoreFoundation 0x31c58cb2 __CFRunLoopRun + 642
26 CoreFoundation 0x31bcbeb8 CFRunLoopRunSpecific + 352
27 CoreFoundation 0x31bcbd44 CFRunLoopRunInMode + 100
28 GraphicsServices 0x399c92e6 GSEventRunModal + 70
29 UIKit 0x394872f4 UIApplicationMain + 1116
30 ourapp 0x000be76a 0xba000 + 18282
31 ourapp 0x000bb684 0xba000 + 5764
Are there any other chances I can get more info out of this situation? How can I plug it in to XCode and possibly trace the crash or it can only be done post-factum?
And most importantly, what do you think is causing the crash?
Our problem was connected with Core Data lightweight migration. We were using the "Magical Record" library for handling our Core Data fetches and updating it solved the problem.
Also, this blog post was quite useful.
Related
Running an iPhone app using the latest version of AFNetworking, the most popular crash according to Crashlytics is involving NSBlockOperation. I am unsure whether AFNetworking is responsible or not. The log from Crashlytics:
Exception Type: EXC_BAD_ACCESS Code: KERN_INVALID_ADDRESS at 0x2985118298
5com.apple.NSURLConnectionLoader Crashed
0 libobjc.A.dylib objc_msgSend + 9
1 Foundation -[NSBlockOperation main] + 200
2 Foundation -[__NSOperationInternal start] + 840
3 Foundation -[_NSCFURLProtocolBridgeWithTrampoline processEventQ] + 344
4 Foundation -[_NSCFURLProtocolBridgeWithTrampoline pushEvent:from:] + 298
5 Foundation -[_NSCFURLProtocolBridge stop] + 88
6 Foundation _bridger + 64
7 CFNetwork __block_global_7 + 24
8 CFNetwork __block_global_8 + 12
9 CFNetwork ___performAsync_block_invoke_068 + 18
10 CoreFoundation CFArrayApplyFunction + 176
11 CFNetwork RunloopBlockContext::perform() + 74
12 CFNetwork MultiplexerSource::perform() + 188
13 ... CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
14 CoreFoundation __CFRunLoopDoSources0 + 212
15 CoreFoundation __CFRunLoopRun + 646
16 CoreFoundation CFRunLoopRunSpecific + 356
17 CoreFoundation CFRunLoopRunInMode + 104
18 Foundation +[NSURLConnection(Loader) _resourceLoadLoop:] + 308
19 Foundation __NSThread__main__ + 972
20 libsystem_c.dylib _pthread_start + 308
Let me know if you need more logs. Can anybody direct me in the direction to avoid this crash? Out of 2500 users 76 users has been affected.
Update Sept 17:
Seems like this guy is having the same problem:
iOS Blocks Async Callbacks Causing Crash after View Controller is deallocated.
I don't understand why this is crashing, whenever i came back to home page this app crashes, I have a file LocationSelectViewController.m when enabling zombie it throws an error
[LocationSelectViewController respondsToSelector:]: message sent to deallocated instance 0x27b96740
Let me share a crash log
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libobjc.A.dylib 0x3b2665d0 objc_msgSend + 16
1 MapKit 0x343b7492 -[MKReverseGeocoder _notifyResult:] + 70
2 ProtocolBuffer 0x389631b6 -[PBRequester connectionDidFinishLoading:] + 1042
3 Foundation 0x33eac912 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 14
4 Foundation 0x33dec764 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 196
5 Foundation 0x33dec680 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 56
6 CFNetwork 0x3324d64c ___delegate_didFinishLoading_block_invoke_0 + 24
7 CFNetwork 0x3324cd30 ___withDelegateAsync_block_invoke_0 + 52
8 CFNetwork 0x33275010 ___performAsync_block_invoke_068 + 16
9 CoreFoundation 0x334b6aca CFArrayApplyFunction + 174
10 CFNetwork 0x3327546e RunloopBlockContext::perform() + 70
11 CFNetwork 0x331d945e MultiplexerSource::perform() + 186
12 CoreFoundation 0x335458f4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
13 CoreFoundation 0x33545158 __CFRunLoopDoSources0 + 208
14 CoreFoundation 0x33543f2a __CFRunLoopRun + 642
15 CoreFoundation 0x334b7238 CFRunLoopRunSpecific + 352
16 CoreFoundation 0x334b70c4 CFRunLoopRunInMode + 100
17 GraphicsServices 0x37096336 GSEventRunModal + 70
18 UIKit 0x353d32b4 UIApplicationMain + 1116
19 PlanetTran 0x000af534 0xae000 + 5428
20 PlanetTran 0x000af4cc 0xae000 + 5324
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x3b74f5d0 kevent64 + 24
1 libdispatch.dylib 0x3b68ad22 _dispatch_mgr_invoke + 806
2 libdispatch.dylib 0x3b686374 _dispatch_mgr_thread + 32
Try to convert your application in ARC(Automatic reference counting).
message sent to deallocated instance means you are trying to send the message that object is destroyed Automatically so you are getting this exceptions.
For converting in ARC goto Xcode
Edit->Refactor->convert to objective c ARC
The last call objc_msgSend tells that it may be Zombie Messaged, but it's in the Core Data library code...
Exception Type: EXC_CRASH (SIGSEGV)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 1
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libobjc.A.dylib 0x37a6ef78 objc_msgSend + 16
1 CoreData 0x3601a748 -[_CDSnapshot dealloc] + 60
2 CoreData 0x3601a336 -[_CDSnapshot release] + 118
3 CoreData 0x3601a6c4 _NSQLRow_dealloc_standard + 52
4 CoreData 0x3601a67c _PFfastRowRelease + 24
5 CoreFoundation 0x35692936 __CFDictionaryReleaseValue + 26
6 CoreFoundation 0x356e6104 __CFBasicHashRemoveValue + 96
7 CoreFoundation 0x3561a7e4 CFBasicHashRemoveValue + 2900
8 CoreFoundation 0x35619c60 CFDictionaryRemoveValue + 172
9 CoreData 0x3601a62e -[NSPersistentStoreCache decrementRefCountForObjectID:] + 66
10 CoreData 0x3601a5b0 -[NSSQLCore managedObjectContextDidUnregisterObjectsWithIDs:] + 124
11 CoreData 0x3601a4f6 -[NSPersistentStoreCoordinator(_NSInternalMethods) _informAffectedStoresOfInterestByChildContextInObjectsWithObjectIDs:withSelector:] + 414
12 CoreData 0x3601af34 -[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 1800
13 CoreData 0x3606a1f6 -[NSManagedObjectContext _mergeChangesFromDidSaveDictionary:usingObjectIDs:] + 2078
14 CoreData 0x36069092 -[NSManagedObjectContext mergeChangesFromContextDidSaveNotification:] + 182
15 Messenger -[WXManagedObjectContextManager managedObjectContextDidSave:] (in Messenger) (WXManagedObjectContextManager.m:106)
16 CoreFoundation 0x3562c1f4 -[NSObject performSelector:withObject:] + 36
17 Foundation 0x351f0740 __NSThreadPerformPerform + 344
18 CoreFoundation 0x356a1acc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 8
19 CoreFoundation 0x356a1298 __CFRunLoopDoSources0 + 208
20 CoreFoundation 0x356a003e __CFRunLoopRun + 646
21 CoreFoundation 0x3562349e CFRunLoopRunSpecific + 294
22 CoreFoundation 0x35623366 CFRunLoopRunInMode + 98
23 GraphicsServices 0x372bf432 GSEventRunModal + 130
24 UIKit 0x3312fcce UIApplicationMain + 1074
25 Messenger 0x000034fc 0x1000 + 9468
26 Messenger 0x00003468 0x1000 + 9320
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x35f733a8 kevent + 24
1 libdispatch.dylib 0x3455df04 _dispatch_mgr_invoke + 708
2 libdispatch.dylib 0x3455dc22 _dispatch_mgr_thread + 30
May be its problem from begin so use any option from bellow ways..
set exception breakpoint in your application and for that follow this link ios-5-xcode-backtrace.
OR
2.Try to run the application with NSZombieEnabled from this link how-to-enable-nszombie-in-xcode also
I am keep getting this error for NSFetchedResultsControllerDelegate.
not sure what to do with it, since it happen sporadically.
I do create the records synchronized, but still ..
any ideas why could this be?
- (Activity *)createActivityWithDictionary:(NSDictionary*)dict
{
#synchronized([DBController sharedManaged])
{
Activity *act = [Activity activityWithDictionary:dict inManagedObjectContext:self.managedObjectContext];
[self saveContext];
return act;
}
}
Date/Time: 2012-09-18 22:55:53.686 -0700
OS Version: iPhone OS 5.1.1 (9B206)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x3724188f __exceptionPreprocess + 163
1 libobjc.A.dylib 0x34f46259 objc_exception_throw + 33
2 CoreFoundation 0x37244a9b -[NSObject doesNotRecognizeSelector:] + 175
3 CoreFoundation 0x37243915 ___forwarding___ + 301
4 CoreFoundation 0x3719e650 _CF_forwarding_prep_0 + 48
5 CoreData 0x36a78f4d -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 2401
6 Foundation 0x37aa64ff __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 19
7 CoreFoundation 0x3720d547 ___CFXNotificationPost_block_invoke_0 + 71
8 CoreFoundation 0x37199097 _CFXNotificationPost + 1407
9 Foundation 0x37a1a3eb -[NSNotificationCenter postNotificationName:object:userInfo:] + 67
10 CoreData 0x36a00839 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 77
11 CoreData 0x36a0031d -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 305
12 CoreData 0x36a09d01 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1245
13 CoreData 0x369fd145 -[NSManagedObjectContext save:] + 201
14 PalFinds 0x000a57cb -[DBController saveContext] (DBController.m:75)
15 PalFinds 0x000a8dff -[DBController createActivityWithDictionaries:] (DBController.m:852)
16 PalFinds 0x00086649 -[PFMe finishRequest:andRestConnection:] (PFMe.m:1986)
17 PalFinds 0x0002e17d -[RestConnection connectionDidFinishLoading:] (RestConnection.m:326)
18 Foundation 0x37addc29 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 17
19 Foundation 0x37a356d9 -[NSURLConnectionInternalConnection invokeForDelegate:] + 29
20 Foundation 0x37a356a3 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 199
21 Foundation 0x37a355c5 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 61
22 CFNetwork 0x36ed97f5 URLConnectionClient::_clientDidFinishLoading(URLConnectionClient::ClientConnectionEventQueue*) + 193
23 CFNetwork 0x36ece4a5 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 425
24 CFNetwork 0x36ece599 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 669
25 CFNetwork 0x36ece599 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 669
26 CFNetwork 0x36ece1a3 URLConnectionClient::processEvents() + 107
27 CFNetwork 0x36ece0d9 MultiplexerSource::perform() + 157
28 CoreFoundation 0x37215ad3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
29 CoreFoundation 0x3721529f __CFRunLoopDoSources0 + 215
30 CoreFoundation 0x37214045 __CFRunLoopRun + 653
31 CoreFoundation 0x371974a5 CFRunLoopRunSpecific + 301
32 CoreFoundation 0x3719736d CFRunLoopRunInMode + 105
33 GraphicsServices 0x33956439 GSEventRunModal + 137
34 UIKit 0x30f43cd5 UIApplicationMain + 1081
35 PalFinds 0x000038bf main (main.mm:14)
36 PalFinds 0x00003878 start + 40
Looks like it's trying to call the delegate back and the delegate isn't implementing a method it's supposed to.
I'm thinking either controller:didChangeObject:atIndexPath:forChangeType:newIndexPath: or controllerDidChangeContent:
Did you implement those methods in your NSFetchedResultsControllerDelegate?
I know this might seem far fetched BUT I had a very similar problem and I had all those methods implemented and then I realized I had my release commented out for the fetchedREsultsController...once I put that back in no more sigbart and works like a charm.
All I'm saying is that sometimes the error isn't always the obvious.
We would need to see a bit more code to figure it out. Thanks.
I got very weird issue with managedObjectContext:save. It hasn't happened at the first time I save the context, it only happens at some point of my program. Could you help me to know why it happened and where should I should find a bug in my code? Thanks.
Here is the log:
-[NSCFNumber UTF8String]: unrecognized selector sent to instance 0x5a64110
2011-05-19 16:02:43.235 DMC to Go[98212:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber UTF8String]: unrecognized selector sent to instance 0x5a64110'
*** Call stack at first throw:
(
0 CoreFoundation 0x015d85a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0172c313 objc_exception_throw + 44
2 CoreFoundation 0x015da0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01549966 ___forwarding___ + 966
4 CoreFoundation 0x01549522 _CF_forwarding_prep_0 + 50
5 CoreData 0x002f870f -[NSSQLiteConnection execute] + 1231
6 CoreData 0x0034aebd -[NSSQLiteConnection updateRow:] + 365
7 CoreData 0x00349e64 -[NSSQLConnection performAdapterOperations:] + 180
8 CoreData 0x00349b0e -[NSSQLCore _performChangesWithAdapterOps:] + 494
9 CoreData 0x003485ea -[NSSQLCore performChanges] + 410
10 CoreData 0x00342038 -[NSSQLCore saveChanges:] + 216
11 CoreData 0x00300199 -[NSSQLCore executeRequest:withContext:error:] + 409
12 CoreData 0x003b070b -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 3691
13 CoreData 0x00338948 -[NSManagedObjectContext save:] + 712
14 DMC to Go 0x0000313b -[dmcIpadAppDelegate saveManagedObjectChanges] + 107
15 DMC to Go 0x00020dc5 +[DmcIpadAppDelegate saveManagedObjectChanges] + 117
16 DMC to Go 0x00027883 -[DownloadFileService observeValueForKeyPath:ofObject:change:context:] + 867
17 Foundation 0x00fae1e4 NSKeyValueNotifyObserver + 361
18 Foundation 0x00fadca6 NSKeyValueDidChange + 384
19 Foundation 0x00f943e2 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 123
20 DMC to Go 0x0002c674 -[DownloadManager connectionDidFinishLoading:] + 836
21 Foundation 0x00fd4112 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
22 Foundation 0x00fd406b _NSURLConnectionDidFinishLoading + 133
23 CFNetwork 0x01dd948e _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 220
24 CFNetwork 0x01ea46e1 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 293
25 CFNetwork 0x01dcfc80 _ZN19URLConnectionClient13processEventsEv + 100
26 CFNetwork 0x01dcfacf _ZN17MultiplexerSource7performEv + 251
27 CoreFoundation 0x015b98ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
28 CoreFoundation 0x0151788b __CFRunLoopDoSources0 + 571
29 CoreFoundation 0x01516d86 __CFRunLoopRun + 470
30 CoreFoundation 0x01516840 CFRunLoopRunSpecific + 208
31 CoreFoundation 0x01516761 CFRunLoopRunInMode + 97
32 GraphicsServices 0x0202a1c4 GSEventRunModal + 217
33 GraphicsServices 0x0202a289 GSEventRun + 115
34 UIKit 0x00838c93 UIApplicationMain + 1160
35 DMC to Go 0x00001f59 main + 121
36 DMC to Go 0x00001ed5 start + 53
37 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Current language: auto; currently objective-c
Make sure you have no warnings
Put breakpoints in your code where you think you are setting an NSString on your object
And/Or NSLog %# the class of NSString properties of your core data objects and make sure it is some variation of an NSString. (NSLog(#"%#", [obj.property class]);)
What is happening is something that you are saving has an NSNumber object in place of an NSString. Since NSNumber does not respond to UTF8String your application is crashing.