views:

68

answers:

3

Hi,

I got a crash report and the crashing thread's call stack all show Apple's code. From the looks of it, Core Data's undo manager is accessing an invalid pointer in -[NSManagedObject(_NSInternalMethods) _newSnapshotForUndo__] + 356. I've googled the point of crash and the only other similar crash log I found was from Sequel Pro crash log.

Here is the particular crash log that I am looking at. Is there any hope I can fix this? How? I couldn't replicate the issue.

Code Type: X86-64 (Native)
Parent Process: launchd [184]

Date/Time: 2010-07-16 18:23:38.505 -0800
OS Version: Mac OS X 10.6.4 (10F569)
Report Version: 6

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Application Specific Information:
objc[27141]: garbage collection is ON

Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 com.apple.CoreData 0x00007fff8602a7c4 -[NSManagedObject(_NSInternalMethods) _newSnapshotForUndo__] + 356
1 com.apple.CoreData 0x00007fff8602a3da -    [NSManagedObjectContext(_NSInternalChangeProcessing) _registerUndoForOperation:withObjects:withExtraArguments:] + 218
2 com.apple.CoreData 0x00007fff8602a2f2 -[NSManagedObjectContext(_NSInternalChangeProcessing) _registerUndoForModifiedObjects:] + 34
3 com.apple.CoreData 0x00007fff85ff9933 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1155
4 com.apple.CoreData 0x00007fff86035e72 -[NSManagedObjectContext processPendingChanges] + 18
5 com.apple.CoreData 0x00007fff8604ca1c -    [NSManagedObjectContext(_NSInternalNotificationHandling) _processEndOfEventNotification:] + 108
6 com.apple.CoreData 0x00007fff86029c6e -[NSManagedObjectContext(_NSInternalChangeProcessing) _undoManagerCheckpoint:] + 30
7 com.apple.Foundation 0x00007fff8460784e _nsnote_callback + 167
8 com.apple.CoreFoundation 0x00007fff842d0a90 __CFXNotificationPost + 1008
9 com.apple.CoreFoundation 0x00007fff842bd008 _CFXNotificationPostNotification + 200
10 com.apple.Foundation 0x00007fff845fe7b8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 101
11 com.apple.Foundation 0x00007fff8466f557 -[NSUndoManager _postCheckpointNotification] + 74
12 com.apple.Foundation 0x00007fff8466f3b9 -[NSUndoManager _endUndoGroupRemovingIfEmpty:] + 86
13 com.apple.Foundation 0x00007fff8461ea71 +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 455
14 com.apple.AppKit 0x00007fff82819945 -[NSApplication run] + 509
15 com.apple.AppKit 0x00007fff828125f8 NSApplicationMain + 364

Thanks in advance.

A: 

Hard to say what is causing the problem given the info you have.

It looks like perhaps the context and the undo manager have gotten out of sync. Check any custom validation code you might have to see if it will ever populate a required attribute or relationship with nil if the validation fails.

TechZen
There isn't any custom validation code though.. at least none that I've written myself. All properties are either optional or has default values.
adib
A: 

Start off by running in the debugger with a breakpoint on objc_exception_throw which will cause your app to halt just before the crash. This will give you a hint about the cause of the crash.

Marcus S. Zarra
I still don't know how to reproduce the crash though.
adib
A: 

I've finally found the fix for this -- simply don't use NSManagedObjectContext in a background thread that saves. I've changed my approach to rely only on the main thread for Core Data operations and it works.

For some background information, this code is part of of the refresh cycle for News Anchor for Mac OS X, an RSS reader that reads feeds out loud. The cycle's purpose is to load RSS feeds from the Internet and create news channel episodes from the feed articles.

adib