2
votes

I'm developing an iPad app centred around a newsletter style interface. I'm using Apple's UIPageViewController to do this.

I'm getting a lot of errors I don't fully understand and I'm hoping someone can help get me on my way to a solution.

While turning the page in this interface, very occasionally (and that's what makes it so frustrating, as it's not easy to replicate) the app freezes. I pause the app in the debugger and this is what it shows me http://cl.ly/image/1y3c2x351t0T.

It's clear to me this is a Core Data related error. It's happened before while doing fetch requests. I thought I solved it but it keeps on returning.

- (void)setupBlockViews{
//Setup the block views in the correct order

NSMutableArray *blockViewsInUse = [[[NSMutableArray alloc] init] autorelease];
for(NLNewsletterPageBlock *pageBlock in self.page.pageBlocks){
    NLNewsletterPageBlockView *blockView = [self blockViewForBlock:pageBlock];
    if(blockView){
        blockView.parentPageVC = self;
        [blockViewsInUse addObject:blockView];
    }
}

//recycle block views if needed
if(RECYCLE_BLOCK_VIEWS){
    NSMutableArray *oldBlockViews = [[[NSMutableArray alloc] init] autorelease];
    for(NLNewsletterPageBlockView *blockView in self.blockViews){
        if(![blockViewsInUse containsObject:blockView]){
            [oldBlockViews addObject:blockView];
        }
    }

    for(NLNewsletterPageBlockView *blockView in oldBlockViews){
        [blockView prepareForReuse];
    }
    [self.recycledBlockViews addObjectsFromArray:oldBlockViews];
}

self.blockViews = blockViewsInUse;

[self layoutBlockViews];
}

The method above, setupBlockViews is called in the UIPageViewController delegate method pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation.

In this particular instance the error occurs while trying to access a fetched property of a NSManagedObject. i.e. self.page.pageBlocks

I have ensured many times that I'm following all the rules of threads, Core Data and managed object contexts, so I don't think it is related to threading and Core Data.

Can anyone make any sense of this? And what could be going on here?

Thanks.

Here's the stack trace:

 
* thread #1: tid = 0x1c03, 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10, stop reason = signal SIGSTOP
    frame #0: 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x9a0f919b libsystem_c.dylib`pthread_mutex_lock + 595
    frame #2: 0x013efb01 CoreData`-[_PFLock lock] + 33
    frame #3: 0x013efada CoreData`-[NSPersistentStoreCoordinator lock] + 42
    frame #4: 0x0140457e CoreData`-[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1182
    frame #5: 0x014029c9 CoreData`-[NSManagedObjectContext executeFetchRequest:error:] + 569
    frame #6: 0x0145ddfa CoreData`-[NSFaultHandler retainedFulfillAggregateFaultForObject:andRelationship:withContext:] + 298
    frame #7: 0x0148b5cf CoreData`-[_NSFaultingMutableArray willRead] + 143
    frame #8: 0x0148baf3 CoreData`-[_NSFaultingMutableArray countByEnumeratingWithState:objects:count:] + 35
    frame #9: 0x0000858c iNewsletter`-[NLNewsletterPageViewController setupBlockViews](self=0x1282ff30, _cmd=0x002e1491) + 206 at NLNewsletterPageViewController.m:408
    frame #10: 0x00007724 iNewsletter`-[NLNewsletterPageViewController updateLowFootprint](self=0x1282ff30, _cmd=0x002e0ad7) + 62 at NLNewsletterPageViewController.m:253
    frame #11: 0x0000495b iNewsletter`-[NLNewsletterViewController pageForIndex:](, _cmd=0x002e09cc) + 884 at NLNewsletterViewController.m:392
    frame #12: 0x00009fc2 iNewsletter`-[NLNewsletterVC_AppleStyle goToPage:animated:](, _cmd=0x002e0afd) + 209 at NLNewsletterVC_AppleStyle.m:163
    frame #13: 0x00006781 iNewsletter`-[NLNewsletterViewController thumbnailPVRecievedTouch:withEvent:](, _cmd=0x002e0949, sender=0x128bb9d0) + 667 at NLNewsletterViewController.m:779
    frame #14: 0x02aac705 libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 77
    frame #15: 0x019e3920 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 96
    frame #16: 0x019e38b8 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    frame #17: 0x01aa4671 UIKit`-[UIControl sendAction:to:forEvent:] + 66
    frame #18: 0x01aa4bcf UIKit`-[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
    frame #19: 0x01aa3d38 UIKit`-[UIControl touchesEnded:withEvent:] + 546
    frame #20: 0x01a1333f UIKit`-[UIWindow _sendTouchesForEvent:] + 846
    frame #21: 0x01a13552 UIKit`-[UIWindow sendEvent:] + 273
    frame #22: 0x019f13aa UIKit`-[UIApplication sendEvent:] + 436
    frame #23: 0x019e2cf8 UIKit`_UIApplicationHandleEvent + 9874
    frame #24: 0x03472df9 GraphicsServices`_PurpleEventCallback + 339
    frame #25: 0x03472ad0 GraphicsServices`PurpleEventCallback + 46
    frame #26: 0x00c80bf5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    frame #27: 0x00c80962 CoreFoundation`__CFRunLoopDoSource1 + 146
    frame #28: 0x00cb1bb6 CoreFoundation`__CFRunLoopRun + 2118
    frame #29: 0x00cb0f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #30: 0x00cb0e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #31: 0x034717e3 GraphicsServices`GSEventRunModal + 88
    frame #32: 0x03471668 GraphicsServices`GSEventRun + 104
    frame #33: 0x019e065c UIKit`UIApplicationMain + 1211
    frame #34: 0x00002385 iNewsletter`main(argc=1, argv=0xbffff390) + 83 at main.m:16

  thread #3: tid = 0x2203, 0x99d779ca libsystem_kernel.dylib`kevent64 + 10
    frame #0: 0x99d779ca libsystem_kernel.dylib`kevent64 + 10
    frame #1: 0x02d3fc2b libdispatch.dylib`_dispatch_mgr_invoke + 863
    frame #2: 0x02d3f8cc libdispatch.dylib`_dispatch_mgr_thread + 61

  thread #5: tid = 0x2403, 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #0: 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x99d73cb0 libsystem_kernel.dylib`mach_msg + 68
    frame #2: 0x00caca49 CoreFoundation`__CFRunLoopServiceMachPort + 185
    frame #3: 0x00cb18d4 CoreFoundation`__CFRunLoopRun + 1380
    frame #4: 0x00cb0f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #5: 0x00cb0e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #6: 0x06c67310 WebCore`RunWebThread(void*) + 608
    frame #7: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

  thread #6: tid = 0x2503, 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #0: 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x99d73cb0 libsystem_kernel.dylib`mach_msg + 68
    frame #2: 0x00caca49 CoreFoundation`__CFRunLoopServiceMachPort + 185
    frame #3: 0x00cb18d4 CoreFoundation`__CFRunLoopRun + 1380
    frame #4: 0x00cb0f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #5: 0x00cb0e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #6: 0x0259bebe Foundation`+[NSURLConnection(Loader) _resourceLoadLoop:] + 393
    frame #7: 0x024e40d5 Foundation`-[NSThread main] + 76
    frame #8: 0x024e4034 Foundation`__NSThread__main__ + 1304
    frame #9: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

  thread #9: tid = 0x2803, 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #0: 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x9a0f919b libsystem_c.dylib`pthread_mutex_lock + 595
    frame #2: 0x013efb01 CoreData`-[_PFLock lock] + 33
    frame #3: 0x013efada CoreData`-[NSPersistentStoreCoordinator lock] + 42
    frame #4: 0x014040cc CoreData`-[NSManagedObjectContext(_NSInternalAdditions) lockObjectStore] + 76
    frame #5: 0x0146164a CoreData`-[NSManagedObjectContext(_NSInternalAdditions) _dispose:] + 490
    frame #6: 0x014611c5 CoreData`-[NSManagedObjectContext _dealloc__] + 325
    frame #7: 0x01461077 CoreData`-[NSManagedObjectContext dealloc] + 103
    frame #8: 0x0006927e iNewsletter`-[RHManagedObjectContext dealloc](self=0x0b04c880, _cmd=0x02d4dabe) + 176 at RHManagedObjectContextManager.m:53
    frame #9: 0x014262f1 CoreData`-[NSManagedObjectContext release] + 81
    frame #10: 0x00c8741c CoreFoundation`CFRelease + 108
    frame #11: 0x00d8ed1e CoreFoundation`-[__NSDictionaryM dealloc] + 158
    frame #12: 0x02aac9ff libobjc.A.dylib`-[NSObject release] + 47
    frame #13: 0x0248ddcd Foundation`__NSFinalizeThreadData + 1295
    frame #14: 0x00cbf5e2 CoreFoundation`__CFTSDFinalize + 98
    frame #15: 0x9a0fa9c7 libsystem_c.dylib`_pthread_tsd_cleanup + 206
    frame #16: 0x9a0f380f libsystem_c.dylib`_pthread_exit + 145
    frame #17: 0x9a0f60b5 libsystem_c.dylib`_pthread_workq_return + 54
    frame #18: 0x9a0f5e79 libsystem_c.dylib`_pthread_wqthread + 448

  thread #13: tid = 0x2c03, 0x99d76be6 libsystem_kernel.dylib`select$DARWIN_EXTSN + 10
    frame #0: 0x99d76be6 libsystem_kernel.dylib`select$DARWIN_EXTSN + 10
    frame #1: 0x00ceecb7 CoreFoundation`__CFSocketManager + 1255
    frame #2: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

  thread #15: tid = 0x2e03, 0x99d768e2 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #0: 0x99d768e2 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x9a0f8280 libsystem_c.dylib`_pthread_cond_wait + 833
    frame #2: 0x9a17e0e0 libsystem_c.dylib`pthread_cond_timedwait$UNIX2003 + 70
    frame #3: 0x07fcc82b JavaScriptCore`WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 123
    frame #4: 0x07fa0bd9 JavaScriptCore`JSC::BlockAllocator::blockFreeingThreadMain() + 121
    frame #5: 0x07fcbb8c JavaScriptCore`WTF::threadEntryPoint(void*) + 76
    frame #6: 0x07fcc0e5 JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 21
    frame #7: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

  thread #16: tid = 0x2f03, 0x99d768e2 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #0: 0x99d768e2 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x9a0f8280 libsystem_c.dylib`_pthread_cond_wait + 833
    frame #2: 0x9a17e095 libsystem_c.dylib`pthread_cond_wait$UNIX2003 + 71
    frame #3: 0x07ed0ad7 JavaScriptCore`JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode) + 439
    frame #4: 0x07ed085a JavaScriptCore`JSC::MarkStackThreadSharedData::markingThreadMain() + 234
    frame #5: 0x07fcbb8c JavaScriptCore`WTF::threadEntryPoint(void*) + 76
    frame #6: 0x07fcc0e5 JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 21
    frame #7: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

  thread #17: tid = 0x3003, 0x99d770ee libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x99d770ee libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x9a0f60ac libsystem_c.dylib`_pthread_workq_return + 45
    frame #2: 0x9a0f5e79 libsystem_c.dylib`_pthread_wqthread + 448

  thread #19: tid = 0x3203, 0x99d770ee libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x99d770ee libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x9a0f60ac libsystem_c.dylib`_pthread_workq_return + 45
    frame #2: 0x9a0f5e79 libsystem_c.dylib`_pthread_wqthread + 448

  thread #21: tid = 0x3403, 0x99d770ee libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x99d770ee libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x9a0f60ac libsystem_c.dylib`_pthread_workq_return + 45
    frame #2: 0x9a0f5e79 libsystem_c.dylib`_pthread_wqthread + 448

  thread #22: tid = 0x3503, 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #0: 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x9a0f919b libsystem_c.dylib`pthread_mutex_lock + 595
    frame #2: 0x013efb01 CoreData`-[_PFLock lock] + 33
    frame #3: 0x013efada CoreData`-[NSPersistentStoreCoordinator lock] + 42
    frame #4: 0x014040cc CoreData`-[NSManagedObjectContext(_NSInternalAdditions) lockObjectStore] + 76
    frame #5: 0x014219c2 CoreData`_PFFaultHandlerLookupRow + 306
    frame #6: 0x01421887 CoreData`-[NSFaultHandler fulfillFault:withContext:forIndex:] + 39
    frame #7: 0x014214c1 CoreData`_PF_FulfillDeferredFault + 225
    frame #8: 0x01421336 CoreData`_sharedIMPL_pvfk_core + 70
    frame #9: 0x014521a0 CoreData`_pvfk_3 + 32
    frame #10: 0x000063ab iNewsletter`-[NLNewsletterViewController thumbnailPickerView:imageAtIndex:](, _cmd=0x002e0f16, thumbnailPickerView=0x128bb9d0) + 239 at NLNewsletterViewController.m:723
    frame #11: 0x000515c5 iNewsletter`__33-[ThumbnailPickerView reloadData]_block_invoke119(.block_descriptor=0x128c2fc0) + 81 at ThumbnailPickerView.m:230
    frame #12: 0x02d3a53f libdispatch.dylib`_dispatch_call_block_and_release + 15
    frame #13: 0x02d4c014 libdispatch.dylib`_dispatch_client_callout + 14
    frame #14: 0x02d3c418 libdispatch.dylib`_dispatch_queue_drain + 239
    frame #15: 0x02d3c2a6 libdispatch.dylib`_dispatch_queue_invoke + 59
    frame #16: 0x02d3d280 libdispatch.dylib`_dispatch_root_queue_drain + 231
    frame #17: 0x02d3d450 libdispatch.dylib`_dispatch_worker_thread2 + 39
    frame #18: 0x9a0f5e72 libsystem_c.dylib`_pthread_wqthread + 441

  thread #14: tid = 0x2d03, 0x99d770ee libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x99d770ee libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x9a0f60ac libsystem_c.dylib`_pthread_workq_return + 45
    frame #2: 0x9a0f5e79 libsystem_c.dylib`_pthread_wqthread + 448

  thread #24: tid = 0x3703, 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #0: 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x99d73cb0 libsystem_kernel.dylib`mach_msg + 68
    frame #2: 0x00caca49 CoreFoundation`__CFRunLoopServiceMachPort + 185
    frame #3: 0x00cb18d4 CoreFoundation`__CFRunLoopRun + 1380
    frame #4: 0x00cb0f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #5: 0x00cb0e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #6: 0x068340b0 WebCore`WebCore::runLoaderThread(void*) + 208
    frame #7: 0x07fcbb8c JavaScriptCore`WTF::threadEntryPoint(void*) + 76
    frame #8: 0x07fcc0e5 JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 21
    frame #9: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

And another stack trace the next time it occurred:

thread #1: tid = 0x1c03, 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10, stop reason = signal SIGSTOP
    frame #0: 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x9a0f919b libsystem_c.dylib`pthread_mutex_lock + 595
    frame #2: 0x013efb01 CoreData`-[_PFLock lock] + 33
    frame #3: 0x013efada CoreData`-[NSPersistentStoreCoordinator lock] + 42
    frame #4: 0x014040cc CoreData`-[NSManagedObjectContext(_NSInternalAdditions) lockObjectStore] + 76
    frame #5: 0x014219c2 CoreData`_PFFaultHandlerLookupRow + 306
    frame #6: 0x01421887 CoreData`-[NSFaultHandler fulfillFault:withContext:forIndex:] + 39
    frame #7: 0x014214c1 CoreData`_PF_FulfillDeferredFault + 225
    frame #8: 0x01421336 CoreData`_sharedIMPL_pvfk_core + 70
    frame #9: 0x014521d0 CoreData`_pvfk_4 + 32
    frame #10: 0x00016617 iNewsletter`-[NLNewsletter isReady](self=0x0b058010, _cmd=0x02679b09) + 53 at NLNewsletter.m:175
    frame #11: 0x0002f7f8 iNewsletter`-[NLNewsletterContainerVC displayNewsletter](self=0x10bbe700, _cmd=0x002e4ea8) + 174 at NLNewsletterContainerVC.m:156
    frame #12: 0x0002f743 iNewsletter`-[NLNewsletterContainerVC viewDidFinishPresenting](self=0x10bbe700, _cmd=0x002e1d74) + 79 at NLNewsletterContainerVC.m:145
    frame #13: 0x02aac663 libobjc.A.dylib`-[NSObject performSelector:] + 62
    frame #14: 0x0000b2f2 iNewsletter`__43-[NLStandarVC presentVC:fromView:animated:]_block_invoke(.block_descriptor=0x10b07830) + 289 at NLStandarVC.m:142
    frame #15: 0x0000b499 iNewsletter`__43-[NLStandarVC presentVC:fromView:animated:]_block_invoke105(, finished='\x01') + 24 at NLStandarVC.m:159
    frame #16: 0x01a2b446 UIKit`-[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 223
    frame #17: 0x01a1e3b6 UIKit`-[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 237
    frame #18: 0x01a1e554 UIKit`-[UIViewAnimationState animationDidStop:finished:] + 68
    frame #19: 0x018f67d8 QuartzCore`CA::Layer::run_animation_callbacks(void*) + 284
    frame #20: 0x02d4c014 libdispatch.dylib`_dispatch_client_callout + 14
    frame #21: 0x02d3c7d5 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 296
    frame #22: 0x00cb1af5 CoreFoundation`__CFRunLoopRun + 1925
    frame #23: 0x00cb0f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #24: 0x00cb0e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #25: 0x034717e3 GraphicsServices`GSEventRunModal + 88
    frame #26: 0x03471668 GraphicsServices`GSEventRun + 104
    frame #27: 0x019e065c UIKit`UIApplicationMain + 1211
    frame #28: 0x00002385 iNewsletter`main(argc=1, argv=0xbffff390) + 83 at main.m:16

  thread #3: tid = 0x2203, 0x99d779ca libsystem_kernel.dylib`kevent64 + 10
    frame #0: 0x99d779ca libsystem_kernel.dylib`kevent64 + 10
    frame #1: 0x02d3fc2b libdispatch.dylib`_dispatch_mgr_invoke + 863
    frame #2: 0x02d3f8cc libdispatch.dylib`_dispatch_mgr_thread + 61

  thread #5: tid = 0x2403, 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #0: 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x99d73cb0 libsystem_kernel.dylib`mach_msg + 68
    frame #2: 0x00caca49 CoreFoundation`__CFRunLoopServiceMachPort + 185
    frame #3: 0x00cb18d4 CoreFoundation`__CFRunLoopRun + 1380
    frame #4: 0x00cb0f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #5: 0x00cb0e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #6: 0x06c67310 WebCore`RunWebThread(void*) + 608
    frame #7: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

  thread #7: tid = 0x2603, 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #0: 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x99d73cb0 libsystem_kernel.dylib`mach_msg + 68
    frame #2: 0x00caca49 CoreFoundation`__CFRunLoopServiceMachPort + 185
    frame #3: 0x00cb18d4 CoreFoundation`__CFRunLoopRun + 1380
    frame #4: 0x00cb0f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #5: 0x00cb0e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #6: 0x0259bebe Foundation`+[NSURLConnection(Loader) _resourceLoadLoop:] + 393
    frame #7: 0x024e40d5 Foundation`-[NSThread main] + 76
    frame #8: 0x024e4034 Foundation`__NSThread__main__ + 1304
    frame #9: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

  thread #9: tid = 0x2803, 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #0: 0x99d7691a libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x9a0f919b libsystem_c.dylib`pthread_mutex_lock + 595
    frame #2: 0x013efb01 CoreData`-[_PFLock lock] + 33
    frame #3: 0x013efada CoreData`-[NSPersistentStoreCoordinator lock] + 42
    frame #4: 0x014040cc CoreData`-[NSManagedObjectContext(_NSInternalAdditions) lockObjectStore] + 76
    frame #5: 0x0146164a CoreData`-[NSManagedObjectContext(_NSInternalAdditions) _dispose:] + 490
    frame #6: 0x014611c5 CoreData`-[NSManagedObjectContext _dealloc__] + 325
    frame #7: 0x01461077 CoreData`-[NSManagedObjectContext dealloc] + 103
    frame #8: 0x0006927e iNewsletter`-[RHManagedObjectContext dealloc](self=0x10b14960, _cmd=0x02d4dabe) + 176 at RHManagedObjectContextManager.m:53
    frame #9: 0x014262f1 CoreData`-[NSManagedObjectContext release] + 81
    frame #10: 0x00c8741c CoreFoundation`CFRelease + 108
    frame #11: 0x00d8ed1e CoreFoundation`-[__NSDictionaryM dealloc] + 158
    frame #12: 0x02aac9ff libobjc.A.dylib`-[NSObject release] + 47
    frame #13: 0x0248ddcd Foundation`__NSFinalizeThreadData + 1295
    frame #14: 0x00cbf5e2 CoreFoundation`__CFTSDFinalize + 98
    frame #15: 0x9a0fa9c7 libsystem_c.dylib`_pthread_tsd_cleanup + 206
    frame #16: 0x9a0f380f libsystem_c.dylib`_pthread_exit + 145
    frame #17: 0x9a0f60b5 libsystem_c.dylib`_pthread_workq_return + 54
    frame #18: 0x9a0f5e79 libsystem_c.dylib`_pthread_wqthread + 448

  thread #13: tid = 0x2c03, 0x99d76be6 libsystem_kernel.dylib`select$DARWIN_EXTSN + 10
    frame #0: 0x99d76be6 libsystem_kernel.dylib`select$DARWIN_EXTSN + 10
    frame #1: 0x00ceecb7 CoreFoundation`__CFSocketManager + 1255
    frame #2: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

* thread #15: tid = 0x2e03, 0x99d768e2 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #0: 0x99d768e2 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x9a0f8280 libsystem_c.dylib`_pthread_cond_wait + 833
    frame #2: 0x9a17e0e0 libsystem_c.dylib`pthread_cond_timedwait$UNIX2003 + 70
    frame #3: 0x07fcc82b JavaScriptCore`WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 123
    frame #4: 0x07fa0bd9 JavaScriptCore`JSC::BlockAllocator::blockFreeingThreadMain() + 121
    frame #5: 0x07fcbb8c JavaScriptCore`WTF::threadEntryPoint(void*) + 76
    frame #6: 0x07fcc0e5 JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 21
    frame #7: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

  thread #16: tid = 0x2f03, 0x99d768e2 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #0: 0x99d768e2 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x9a0f8280 libsystem_c.dylib`_pthread_cond_wait + 833
    frame #2: 0x9a17e095 libsystem_c.dylib`pthread_cond_wait$UNIX2003 + 71
    frame #3: 0x07ed0ad7 JavaScriptCore`JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode) + 439
    frame #4: 0x07ed085a JavaScriptCore`JSC::MarkStackThreadSharedData::markingThreadMain() + 234
    frame #5: 0x07fcbb8c JavaScriptCore`WTF::threadEntryPoint(void*) + 76
    frame #6: 0x07fcc0e5 JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 21
    frame #7: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344

  thread #17: tid = 0x3003, 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #0: 0x99d747d2 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x99d73cb0 libsystem_kernel.dylib`mach_msg + 68
    frame #2: 0x00caca49 CoreFoundation`__CFRunLoopServiceMachPort + 185
    frame #3: 0x00cb18d4 CoreFoundation`__CFRunLoopRun + 1380
    frame #4: 0x00cb0f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #5: 0x00cb0e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #6: 0x068340b0 WebCore`WebCore::runLoaderThread(void*) + 208
    frame #7: 0x07fcbb8c JavaScriptCore`WTF::threadEntryPoint(void*) + 76
    frame #8: 0x07fcc0e5 JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 21
    frame #9: 0x9a0f35b7 libsystem_c.dylib`_pthread_start + 344
1
Can you show us the state of all the threads when this deadlock happens? You can press "pause" when the app freezes, and type bt all to log the stack trace of all threads at that point. It does look like a deadlock based on the screenshot you have shown.Anurag
Hi anurag, I updated my post with the stack trace of all threads.user789744
Could you put the whole thing in <blockquote> or <pre> tags so it's easier to read?Anurag

1 Answers

3
votes

I found a piece of code which runs on a background thread that was accessing an NSManagedObject created on the main thread. I missed it before. Mutex error is now gone.