Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash: NSFetchedResultsController + NSObjectInaccessibleException #436

Closed
jleandroperez opened this issue Jan 22, 2015 · 1 comment · Fixed by #439
Closed

Crash: NSFetchedResultsController + NSObjectInaccessibleException #436

jleandroperez opened this issue Jan 22, 2015 · 1 comment · Fixed by #439
Assignees
Labels
Milestone

Comments

@jleandroperez
Copy link
Contributor

Scenario:

  1. Simperium is deleting entities in background.
  2. At the exact same time, there is a NSFetchedResultsController instance running a NSFetchRequest.
  3. Due to the resultsController performFetch: inner workings, objects are initially loaded as faults.
  4. During the FRC's section calculation, the objects will be loaded into memory.

Results:

There is a (really hard to trigger) race condition between steps (1) and (3), in which the objects what were loaded as faults are no longer relevant.

Problem in this scenario is that the NSFetchedResultsController instance is locking the main thread, and thus, preventing the NSManagedObjectContextDidSaveNotification from getting merged. Which, in turn, causes invalid objects to be accessed.

Notes:

This is a side effect of not using NSManagedObjectContext's parenting mechanism, which has been removed due to a Core Data Deadlock (Reference Issue #376).

@jleandroperez jleandroperez self-assigned this Jan 22, 2015
@jleandroperez jleandroperez added this to the v0.7.7 milestone Jan 22, 2015
@jleandroperez
Copy link
Contributor Author

GCD Queue: Main

Thread : Fatal Exception: NSObjectInaccessibleException
0  CoreFoundation                 0x2e24af83 __exceptionPreprocess + 130
1  libobjc.A.dylib                0x389fbccf objc_exception_throw + 38
2  CoreData                       0x2dfafffd _PFFaultHandlerLookupRow + 2436
3  CoreData                       0x2dfaf37d _PF_FulfillDeferredFault + 216
4  CoreData                       0x2dfaf217 _sharedIMPL_pvfk_core + 38
5  WordPress                      0x0012baa9 -[Notification timestampAsDate] (Notification.m:461)
6  WordPress                      0x00075988 @objc ext.WordPress.ObjectiveC.Notification.sectionIdentifier (ObjectiveC.Notification)() -> Swift.String (Notification+Interface.swift:9)
7  Foundation                     0x2eb71bb7 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 294
8  CoreData                       0x2e085d95 -[NSFetchedResultsController(PrivateMethods) _sectionNameForObject:] + 40
9  CoreData                       0x2e086337 -[NSFetchedResultsController(PrivateMethods) _computeSectionInfo:error:] + 1422
10 CoreData                       0x2dfb5ed7 -[NSFetchedResultsController performFetch:] + 666
11 WordPress                      0x0013681f -[WPTableViewController resultsController] (WPTableViewController.m:328)
12 WordPress                      0x00137993 -[WPTableViewController configureNoResultsView] (WPTableViewController.m:547)
13 WordPress                      0x00135b09 -[WPTableViewController viewDidLoad] (WPTableViewController.m:116)
14 WordPress                      0x00116b5d -[NotificationsViewController viewDidLoad] (NotificationsViewController.m:98)
15 UIKit                          0x30a6c4ab -[UIViewController loadViewIfRequired] + 518
16 UIKit                          0x30b16be1 -[UINavigationController _layoutViewController:] + 32
17 UIKit                          0x30b16af7 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 230
18 UIKit                          0x30b160d3 -[UINavigationController _startTransition:fromViewController:toViewController:] + 78
19 UIKit                          0x30b15dfd -[UINavigationController _startDeferredTransitionIfNeeded:] + 572
20 UIKit                          0x30b15b6d -[UINavigationController __viewWillLayoutSubviews] + 44
21 UIKit                          0x30b15b05 -[UILayoutContainerView layoutSubviews] + 184
22 UIKit                          0x30a67d59 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 380
23 QuartzCore                     0x306e562b -[CALayer layoutSublayers] + 142
24 QuartzCore                     0x306e0e3b CA::Layer::layout_if_needed(CA::Transaction*) + 350
25 QuartzCore                     0x306e0ccd CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
26 QuartzCore                     0x306e06df CA::Context::commit_transaction(CA::Transaction*) + 230
27 QuartzCore                     0x306e04ef CA::Transaction::commit() + 314
28 UIKit                          0x30a6040b _afterCACommitHandler + 126
29 CoreFoundation                 0x2e216255 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
30 CoreFoundation                 0x2e213bf9 __CFRunLoopDoObservers + 284
31 CoreFoundation                 0x2e213f3b __CFRunLoopRun + 730
32 CoreFoundation                 0x2e17eebf CFRunLoopRunSpecific + 522
33 CoreFoundation                 0x2e17eca3 CFRunLoopRunInMode + 106
34 GraphicsServices               0x33084663 GSEventRunModal + 138
35 UIKit                          0x30acb14d UIApplicationMain + 1136
36 WordPress                      0x000b550f main (main.m:5)
37 libdyld.dylib                  0x38f08ab7 start + 2

GCD Queue: com.simperium.processor.Notification

Thread : com.simperium.processor.Notification
0  libsystem_kernel.dylib         0x38fabaa8 semaphore_wait_trap + 8
1  libsystem_platform.dylib       0x39020bad _os_semaphore_wait + 12
2  libdispatch.dylib              0x38ef5c3f _dispatch_barrier_sync_f_slow + 134
3  CoreData                       0x2e023a73 -[NSManagedObjectContext performBlockAndWait:] + 106
4  WordPress                      0x0035dba5 -[SPCoreDataStorage childrenContextDidSave:] (SPCoreDataStorage.m:490)
5  CoreFoundation                 0x2e20d1a1 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
6  CoreFoundation                 0x2e1814ef _CFXNotificationPost + 1718
7  Foundation                     0x2eb6ca3d -[NSNotificationCenter postNotificationName:object:userInfo:] + 76
8  CoreData                       0x2dfde3f5 -[NSManagedObjectContext(_NSInternalAdditions) _didSaveChanges] + 2240
9  CoreData                       0x2dfc00ab -[NSManagedObjectContext save:] + 1186
10 WordPress                      0x0035ce79 -[SPCoreDataStorage save] (SPCoreDataStorage.m:361)
11 WordPress                      0x00363e0b -[SPIndexProcessor reconcileLocalAndRemoteIndex:bucket:] (SPIndexProcessor.m:162)
12 WordPress                      0x003635f9 -[SPIndexProcessor processIndex:bucket:versionHandler:] (SPIndexProcessor.m:94)
13 WordPress                      0x00378a79 __52-[SPWebSocketChannel requestVersionsForKeys:bucket:]_block_invoke (SPWebSocketChannel.m:655)
14 libdispatch.dylib              0x38ee3833 _dispatch_call_block_and_release + 10
15 libdispatch.dylib              0x38ee3ded _dispatch_queue_drain$VARIANT$up + 444
16 libdispatch.dylib              0x38ee4297 _dispatch_queue_invoke$VARIANT$up + 38
17 libdispatch.dylib              0x38ef688d _dispatch_root_queue_drain + 76
18 libdispatch.dylib              0x38ef6b21 _dispatch_worker_thread2 + 56
19 libsystem_pthread.dylib        0x39025bd3 _pthread_wqthread + 298

Note: This stack trace was produced by WPiOS 4.6.1 + Simperium Mark 0.7.2

jleandroperez added a commit that referenced this issue Jan 28, 2015
jleandroperez added a commit that referenced this issue Jan 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant