Master data crash during NSManagedObjectContextPendingChanges process

I get (which seems strange to me) with Core Data. From what I can collect, this happens when Core Data performs the save and subsequent managedObjectContextDidSave methods.

I am at a loss and really hope that someone can help me or lead me in the right direction.

The crash report is as follows:

Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000b Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib 0x000026f4 objc_msgSend + 16 1 Foundation 0x000437a4 NSClassFromObject + 8 2 Foundation 0x0000ba54 _NSIMPForObjectAndSelector + 4 3 Foundation 0x00095eae -[NSSortDescriptor compareObject:toObject:] + 110 4 CoreData 0x000b0a6e +[NSFetchedResultsController(PrivateMethods) _insertIndexForObject:inArray:lowIdx:highIdx:sortDescriptors:] + 174 5 CoreData 0x000b1496 -[NSFetchedResultsController(PrivateMethods) _postprocessInsertedObjects:] + 342 6 CoreData 0x000b32d6 -[NSFetchedResultsController(PrivateMethods) _postprocessUpdatedObjects:] + 430 7 CoreData 0x000b2a5e -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 498 8 Foundation 0x0004bbf6 _nsnote_callback + 162 9 CoreFoundation 0x00050af2 _CFXNotificationPostNotification + 298 10 Foundation 0x000497f4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64 11 CoreData 0x0002e42e -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 66 12 CoreData 0x0007fd26 -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 134 13 CoreData 0x0001670a -[NSManagedObjectContext(_NSInternalChangeProcessing) _postRefreshedObjectsNotificationAndClearList] + 70 14 CoreData 0x000164ac -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1656 15 CoreData 0x0004b5fa -[NSManagedObjectContext processPendingChanges] + 10 16 CoreData 0x0003e2a4 _performRunLoopAction + 120 17 CoreFoundation 0x0000fb50 __CFRunLoopDoObservers + 420 18 CoreFoundation 0x00056a32 CFRunLoopRunSpecific + 1734 19 CoreFoundation 0x00056356 CFRunLoopRunInMode + 42 20 GraphicsServices 0x00003cb8 GSEventRunModal + 108 21 GraphicsServices 0x00003d64 GSEventRun + 56 22 UIKit 0x00002768 -[UIApplication _run] + 384 23 UIKit 0x0000146c UIApplicationMain + 688 24 MyApp 0x000022d2 main (main.m:14) 25 MyApp 0x00002248 start + 44 
+4
source share
2 answers

It looks like one of the elements in one of your database arrays is returned too many times (and therefore freed). This is a failure while trying to sort your array, doing a comparison with a freed object.

Try starting your program with NSZombieEnabled - it prevents freeing up so you can see which object receives messages sent to it while keeping counter 0.

+1
source

If you are using NSFetchedResultsController then there might be an error in this code, and it is not easy to see. I would suggest including some log instructions in my NSFetchedResultsController delegation methods and see which one starts.

Since the NSFRC starts as part of the NSManagedObjectContext save procedure, an error in its deletion can easily be interpreted as an error in the save itself.

Update 1

If it is on a date, then perhaps when you set this date somewhere, do you reissue it yourself? Perhaps calling -release on [NSDate date] . This type of error will be hidden until Core Data tries to access the date object.

+1
source

Source: https://habr.com/ru/post/1300132/


All Articles