views:

280

answers:

2

I got this crash log while querying an array of managed object, however, while running in the simulator it does not happen. Even in the device, sometimes it happens, sometimes not. Someone can explain to me why and what is the error?

Incident Identifier: 0ED2BB7C-5E8F-483B-AE08-8DE2C14D0C23
CrashReporter Key:   e24b9614a897f92ee13ce00b76c71db307c61dcb
Process:         FooApp [4141]
Path:            /var/mobile/Applications/8C745160-4129-4369-B201-F55CC42D0466/FooApp.app/FooApp
Identifier:      FooApp
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2010-06-19 20:57:31.548 +0200
OS Version:      iPhone OS 3.1.3 (7E18)
Report Version:  104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0

Thread 0 Crashed:
0   libSystem.B.dylib               0x00090b2c __kill + 8
1   libSystem.B.dylib               0x00090b1a kill + 4
2   libSystem.B.dylib               0x00090b0e raise + 10
3   libSystem.B.dylib               0x000a7e34 abort + 36
4   libstdc++.6.dylib               0x00066390 __gnu_cxx::__verbose_terminate_handler() + 588
5   libobjc.A.dylib                 0x00008898 _objc_terminate + 160
6   libstdc++.6.dylib               0x00063a84 __cxxabiv1::__terminate(void (*)()) + 76
7   libstdc++.6.dylib               0x00063afc std::terminate() + 16
8   libstdc++.6.dylib               0x00063bb0 __cxa_rethrow + 108
9   libobjc.A.dylib                 0x000087c4 objc_exception_rethrow + 8
10  CoreData                        0x0002725e _PFFaultHandlerLookupRow + 1338
11  CoreData                        0x00026d1a -[NSFaultHandler fulfillFault:withContext:] + 14
12  CoreData                        0x00024f8a _PF_FulfillDeferredFault + 354
13  CoreData                        0x0002864c _sharedIMPL_pvfk_core + 48
14  CoreData                        0x00036314 _pvfk_9 + 4
15  FooApp                          0x00004162 -[PNHFeedDataSource tableViewDidLoadModel:] (PNHFeedDataSource.m:47)
16  FooApp                          0x00055244 -[TTTableViewController didLoadModel:] (TTTableViewController.m:395)
17  FooApp                          0x000395fc -[TTModelViewController updateViewStates] (TTModelViewController.m:98)
18  FooApp                          0x00038dce -[TTModelViewController updateView] (TTModelViewController.m:467)
19  FooApp                          0x00039510 -[TTModelViewController viewWillAppear:] (TTModelViewController.m:185)
20  FooApp                          0x000554b2 -[TTTableViewController viewWillAppear:] (TTTableViewController.m:252)
21  UIKit                           0x00088808 -[UINavigationController _startTransition:fromViewController:toViewController:] + 964
22  UIKit                           0x000883a8 -[UINavigationController _startDeferredTransitionIfNeeded] + 256
23  UIKit                           0x000ca130 -[UINavigationController _popViewControllerWithTransition:allowPoppingLast:] + 400
24  UIKit                           0x000c9f90 -[UINavigationController popViewControllerAnimated:] + 32
25  FooApp                          0x0005fc02 -[UINavigationController(TTCategory) popViewControllerAnimated2:] (UINavigationControllerAdditions.m:84)
26  UIKit                           0x000ca500 -[UINavigationController navigationBar:shouldPopItem:] + 132
27  UIKit                           0x00152ba8 -[UINavigationBar _popNavigationItemWithTransition:] + 104
28  UIKit                           0x000ca454 -[UINavigationBar popNavigationItemAnimated:] + 116
29  UIKit                           0x000ee188 -[UINavigationBar _handleMouseUpAtPoint:] + 536
30  UIKit                           0x000edf54 -[UINavigationBar touchesEnded:withEvent:] + 84
31  UIKit                           0x0005a8f8 -[UIWindow _sendTouchesForEvent:] + 520
32  UIKit                           0x00059f8c -[UIWindow sendEvent:] + 108
33  UIKit                           0x00055788 -[UIApplication sendEvent:] + 400
34  UIKit                           0x0005508c _UIApplicationHandleEvent + 4528
35  GraphicsServices                0x000057dc PurpleEventCallback + 1044
36  CoreFoundation                  0x00057524 CFRunLoopRunSpecific + 2296
37  CoreFoundation                  0x00056c18 CFRunLoopRunInMode + 44
38  GraphicsServices                0x000041c0 GSEventRunModal + 188
39  UIKit                           0x00003c28 -[UIApplication _run] + 552
40  UIKit                           0x00002228 UIApplicationMain + 960
41  FooApp                          0x00002510 main (main.m:11)
42  FooApp                          0x000024ac start + 44

Thread 1:
0   libSystem.B.dylib               0x00001488 mach_msg_trap + 20
1   libSystem.B.dylib               0x00004064 mach_msg + 60
2   CoreFoundation                  0x00057002 CFRunLoopRunSpecific + 982
3   CoreFoundation                  0x00056c18 CFRunLoopRunInMode + 44
4   WebCore                         0x000841d4 RunWebThread(void*) + 412
5   libSystem.B.dylib               0x0002b780 _pthread_body + 20

Thread 2:
0   libSystem.B.dylib               0x00001488 mach_msg_trap + 20
1   libSystem.B.dylib               0x00004064 mach_msg + 60
2   CoreFoundation                  0x00057002 CFRunLoopRunSpecific + 982
3   CoreFoundation                  0x00056c18 CFRunLoopRunInMode + 44
4   Foundation                      0x0005a998 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 172
5   Foundation                      0x00053ac6 -[NSThread main] + 42
6   Foundation                      0x00001d0e __NSThread__main__ + 852
7   libSystem.B.dylib               0x0002b780 _pthread_body + 20

Thread 3:
0   libSystem.B.dylib               0x000262c0 select$DARWIN_EXTSN + 20
1   CoreFoundation                  0x000207e2 __CFSocketManager + 342
2   libSystem.B.dylib               0x0002b780 _pthread_body + 20

Thread 4:
0   libSystem.B.dylib               0x000916f0 __semwait_signal + 24
1   libSystem.B.dylib               0x000334a8 _pthread_cond_wait + 1592
2   libSystem.B.dylib               0x00032c6c pthread_cond_wait + 48
3   JavaScriptCore                  0x000071c4 WTF::ThreadCondition::wait(WTF::Mutex&) + 4
4   WebCore                         0x005c00dc WebCore::LocalStorageThread::localStorageThread() + 128
5   libSystem.B.dylib               0x0002b780 _pthread_body + 20

Thread 5:
0   libSystem.B.dylib               0x000916f0 __semwait_signal + 24
1   libSystem.B.dylib               0x000334a8 _pthread_cond_wait + 1592
2   libSystem.B.dylib               0x00032c6c pthread_cond_wait + 48
3   JavaScriptCore                  0x000071c4 WTF::ThreadCondition::wait(WTF::Mutex&) + 4
4   WebCore                         0x005c00dc WebCore::LocalStorageThread::localStorageThread() + 128
5   libSystem.B.dylib               0x0002b780 _pthread_body + 20

Thread 0 crashed with ARM Thread State:
    r0: 0x00000000    r1: 0x00000000      r2: 0x00000001      r3: 0x385333cc
    r4: 0x00000006    r5: 0x040e5a8c      r6: 0x2fffe610      r7: 0x2fffe620
    r8: 0x00000000    r9: 0x0000000a     r10: 0x00000009     r11: 0x0021fc40
    ip: 0x00000025    sp: 0x2fffe620      lr: 0x33994b21      pc: 0x33994b2c
  cpsr: 0x000f0010

Binary Images:
    0x1000 -    0x78fff +FooApp armv6  <5e810908faf129323bdd2bdede3daabd> /var/mobile/Applications/8C745160-4129-4369-B201-F55CC42D0466/FooApp.app/FooApp
  0x189000 -   0x18afff  dns.so armv6  <957f94410f77a351749ac39d2b4b4abe> /usr/lib/info/dns.so
0x2fe00000 - 0x2fe26fff  dyld armv6  <544395a4b5546114b878d5131a84fd7f> /usr/lib/dyld
0x3000e000 - 0x3001afff  DataDetectorsCore armv6  <fd18ffc95012b76c319875bedd99eb43> /System/Library/PrivateFrameworks/DataDetectorsCore.framework/DataDetectorsCore
0x30092000 - 0x300c6fff  Security armv6  <fb2124d1711c8931a7df711d126193d0> /System/Library/Frameworks/Security.framework/Security
0x300ca000 - 0x3021efff  AudioToolbox armv6  <31bb7db82eece25ac6742672e3afbe02> /System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
0x30343000 - 0x3034cfff  SpringBoardServices armv6  <f13747f4598b0f4b1442877adc75de5a> /System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices
0x30490000 - 0x30591fff  libicucore.A.dylib armv6  <a99c2e5d034344c7447a7420db2b36b1> /usr/lib/libicucore.A.dylib
0x30792000 - 0x30799fff  WebUI armv6  <bb2e1be75e3a51511bf16d54af1fa774> /System/Library/PrivateFrameworks/WebUI.framework/WebUI
0x3079a000 - 0x30804fff  libstdc++.6.dylib armv6  <a35cfd59eee09893fbab57794ad7cbaf> /usr/lib/libstdc++.6.dylib
0x30805000 - 0x30902fff  JavaScriptCore armv6  <41bc769b8c046770bac84eed2b08ff42> /System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore
0x30d13000 - 0x30df2fff  CoreData armv6  <20e4f1b34238c3984a7ab05c7edfbce5> /System/Library/Frameworks/CoreData.framework/CoreData
0x30df3000 - 0x30e16fff  libRIP.A.dylib armv6  <a53df8fe2c05c16f671e2502d0d21f60> /System/Library/Frameworks/CoreGraphics.framework/Resources/libRIP.A.dylib
0x30f96000 - 0x30f97fff  CoreSurface armv6  <f27efe4047d6b4319bc01edb9007a789> /System/Library/PrivateFrameworks/CoreSurface.framework/CoreSurface
0x30fba000 - 0x31067fff  ImageIO armv6  <572f72dbfb19a2fd37666bb1d58b13cb> /System/Library/PrivateFrameworks/ImageIO.framework/ImageIO
0x310b3000 - 0x310bdfff  libkxld.dylib armv6  <33215da7e582cbc93ad25bf1cdb8ea62> /usr/lib/system/libkxld.dylib
0x310be000 - 0x31278fff  CoreGraphics armv6  <41796502b08a751095dcd2b105d1931c> /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
0x3138c000 - 0x313aafff  AddressBook armv6  <80bdcada8d61624b2bb0796b7155f570> /System/Library/Frameworks/AddressBook.framework/AddressBook
0x313e2000 - 0x3143dfff  CoreAudio armv6  <71fb4de4976308c0a3f86d127e46472b> /System/Library/Frameworks/CoreAudio.framework/CoreAudio
0x31465000 - 0x314a2fff  libCGFreetype.A.dylib armv6  <b299c486f638e82d10939b7c496b7d78> /System/Library/Frameworks/CoreGraphics.framework/Resources/libCGFreetype.A.dylib
0x31546000 - 0x315f3fff  WebKit armv6  <2bf8152a62e6cbc8a219d80489acb0e7> /System/Library/PrivateFrameworks/WebKit.framework/WebKit
0x31600000 - 0x3164dfff  IOKit armv6  <521cb10d7c6fb9ce21936db07a2587bb> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x316ba000 - 0x316c4fff  DataDetectorsUI armv6  <f84ebef0dfbdd719da4b52b5732e895f> /System/Library/PrivateFrameworks/DataDetectorsUI.framework/DataDetectorsUI
0x31767000 - 0x3176dfff  liblockdown.dylib armv6  <f18aa1ca3cc98cda954fd821ff88a3ac> /usr/lib/liblockdown.dylib
0x318f1000 - 0x3195efff  CFNetwork armv6  <58e56341b7a2a491c727a385b871f7b8> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
0x319c4000 - 0x319fffff  CoreTelephony armv6  <98b8ac66b4615a56958655929505c985> /System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony
0x31a00000 - 0x31a0afff  MobileCoreServices armv6  <805d82b950722ad728d87e0c24089c4b> /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices
0x31a22000 - 0x31a23fff  liblangid.dylib armv6  <f8f20663988ec129b14a4e5a06e1ab0d> /usr/lib/liblangid.dylib
0x31b59000 - 0x31c03fff  QuartzCore armv6  <5cab4e700e90abef71c1b2b695bd897a> /System/Library/Frameworks/QuartzCore.framework/QuartzCore
0x31c04000 - 0x31c38fff  SystemConfiguration armv6  <4b1e9c323f8c973bac2737cdccec8de3> /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration
0x31ca1000 - 0x31cdffff  CoreText armv6  <fe5639949094efc4d973a1f6457a4e5c> /System/Library/PrivateFrameworks/CoreText.framework/CoreText
0x31cff000 - 0x31d03fff  libgermantok.dylib armv6  <9b523938db9da7cd317ed09e4845e4b2> /usr/lib/libgermantok.dylib
0x31d09000 - 0x31dfffff  libxml2.2.dylib armv6  <a2f276df14b4ded9650dea857293b4e9> /usr/lib/libxml2.2.dylib
0x31fd7000 - 0x31ffefff  AppSupport armv6  <db69446acd77981f1d9c968846e4c868> /System/Library/PrivateFrameworks/AppSupport.framework/AppSupport
0x31fff000 - 0x32df0fff  UIKit armv6  <4e881f8351712fd798c335af748b5b5f> /System/Library/Frameworks/UIKit.framework/UIKit
0x32e05000 - 0x32e5ffff  libsqlite3.dylib armv6  <61513660cb3e21b47ccbf5407e0efae5> /usr/lib/libsqlite3.dylib
0x32e78000 - 0x32f70fff  Foundation armv6  <a3612d56db60ccfc998caee19d9805d7> /System/Library/Frameworks/Foundation.framework/Foundation
0x32f71000 - 0x32f79fff  libgcc_s.1.dylib armv6  <6673f222acee5f3a208169712387862a> /usr/lib/libgcc_s.1.dylib
0x32f7a000 - 0x32f91fff  OpenGLES armv6  <8d075dd39e978efae59c70eeedfd858a> /System/Library/Frameworks/OpenGLES.framework/OpenGLES
0x32f9a000 - 0x32fc4fff  MobileQuickLook armv6  <accf1f4b9ad21f4873767c8556f6b48b> /System/Library/PrivateFrameworks/MobileQuickLook.framework/MobileQuickLook
0x33242000 - 0x3324efff  CoreVideo armv6  <63d65206a8853262b597f97b3d949f31> /System/Library/PrivateFrameworks/CoreVideo.framework/CoreVideo
0x3324f000 - 0x3324ffff  vecLib armv6  <c8a08b45effd5eb35a476a969628e52d> /System/Library/PrivateFrameworks/Accelerate.framework/Frameworks/vecLib.framework/vecLib
0x332b2000 - 0x332c2fff  libbsm.0.dylib armv6  <722065615a92c5d0c57395f0aa624b8d> /usr/lib/libbsm.0.dylib
0x332e8000 - 0x332e9fff  IOMobileFramebuffer armv6  <89abbd5846018f4b74250e8cb09eaf4c> /System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer
0x3335f000 - 0x33365fff  MBX2D armv6  <5246c74334f4daf6c0b876605134baa1> /System/Library/PrivateFrameworks/MBX2D.framework/MBX2D
0x33366000 - 0x33409fff  libobjc.A.dylib armv6  <54f0ebeeb9747bf5075f93e2a5043b5e> /usr/lib/libobjc.A.dylib
0x33730000 - 0x3373efff  libz.1.dylib armv6  <7a06dbf4af39c5b548306c7fb8ffcf0b> /usr/lib/libz.1.dylib
0x337df000 - 0x337fdfff  libresolv.9.dylib armv6  <c25b840bd418c833ab6c31a29389445a> /usr/lib/libresolv.9.dylib
0x33856000 - 0x33856fff  Accelerate armv6  <21e1dc9fad96f0d51afbeb7f7e006aaf> /System/Library/PrivateFrameworks/Accelerate.framework/Accelerate
0x33857000 - 0x33903fff  CoreFoundation armv6  <26d25c2c53c05db6e9adc24d5befaa2c> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x33904000 - 0x33a2afff  libSystem.B.dylib armv6  <0373fd64e915a17160732b29d343f95f> /usr/lib/libSystem.B.dylib
0x33a3d000 - 0x33a41fff  IOSurface armv6  <f19a15d8311b851caeba68c1fef33e11> /System/Library/PrivateFrameworks/IOSurface.framework/IOSurface
0x33a42000 - 0x34195fff  WebCore armv6  <65181be01889192c1252e2535531c99c> /System/Library/PrivateFrameworks/WebCore.framework/WebCore
0x3430f000 - 0x34349fff  libvDSP.dylib armv6  <cf9cc6079374718dce29cba9de48b993> /System/Library/PrivateFrameworks/Accelerate.framework/Frameworks/vecLib.framework/libvDSP.dylib
0x3434a000 - 0x34355fff  GraphicsServices armv6  <3a4ec1bf23242cddae5f606f0ed38930> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices

This is the line where 47 of the error:

    for (Item *item in model.items)

Notice that the Item is a Core Data object, and model is the class which contains a NSArray of type Item items, this class is populated with items when the NSXML Parser goes through each downloaded data, whenever it finishes parsing one element, it creates one Item object and saves into the Core Data context. Three20 is used in my project.

+4  A: 

I'm surprised the exception being raised isn't printed. There isn't a lot of evidence to work with here.

In any case, the most likely cause of this is not correctly using threads with Core Data. That is, do you have multiple threads and, if so, are you sure you are properly managing your managed object context(s) across the threads?

bbum
NSManagedObjectContext instances are not thread safe, this is noted in the ADC Class reference. Rule of thumb - use different NSManagedObjectContext instances for each thread while you're working on managed objects. When you're done, merge them together.
Denis 'Alpheus' Čahuk
I agree that the explanation is almost certainly in your logs. You're throwing an exception; it should be printed out. Go look there rather than in the crash stack.
Rob Napier
Thank you for your answers and suggestions, but I did not get the error when doing debug with the simulator, only with the device I got this crash log, try to save it with the Organizer to see why. It says that on the line where I query an instance of a class with its variable an NSArray of items (managedObject) Debug to this line there is no error :-s
sfa
@bbum -- For my own curiosity, what makes you think this is thread related? The crash happened on thread 0 which IIRC is always present.
TechZen
NSManagedObjects are inherently not thread safe and one of the most common causes of crashes at the faulting layer is when a managed object context is mis-used from multiple threads. I.e. if your context was used from a background thread, your main thread could easily crash when using same context.
bbum
The full crash log would be helpful. That it happens on the device but not when debugging or in the simulator also makes it smell like a threading issue; still might not be, but given the lack of information we are "best guessing" the problem.
bbum
I see, it was the location of the error within the Core Data stack itself that raised your suspicions.
TechZen
sfa
+3  A: 

As a general rule of thumb, most crashes that happen on the device only result from some issue with the drive. (Especially if it obviously doesn't involve any other device specific function such as the accelerometer.) The most likely cause is a full drive. All kinds of weird things start happening when the disk gets full.

In this crash, Core Data is attempting to load the attributes of a fault (ghost) object and failing. This can happen when a cache gets out of synch with the store or if you have otherwise create a condition in which the store is altered without the knowledge of the context.

(1) I would start by seeing if the device is full and freeing up some room if it is. Conversely, you could intentionally fill the drive to try and trigger the error consistently.

(2) If you have multiple context, make sure they don't manipulate the same objects at the same time.

Edit:

The error could be caused by the object returned from the model.items not actually being of class "Item" it could be a superclass that lacks the attribute. That would explain why it fails when it tries to fault in (read in) the actual attribute.

Just a guess. Not sure why that would only occur on the device. Is there networking involved here?

More code from around the point of failure might be helpful.

TechZen
hi techzen, thank you for your answer, I edited the question with more exception details. (1) I don't think that the disk is full, because my iPod still has 6GB available, I use a 8GB iPod only for development. (2) I don't use multiple context, only one in the AppDelegate I tried to call the delegate to get the managed object context any time when I need it.
sfa
hi Techzen, the app does use network to download data, save the downloaded data into the context. I got the error randomly when I came back with the navigation controller to the step where it loads the data from the models.items. Debugging with the simulator does not help as it does not raise the error, even with the device, not always it happens. I guess, if the app remains in the current screen for too long and comes back to this screen, it tries to re-read the items but failed, so, there must be some timeouts somewhere with the core data (or the nsarray) to keep the items in memory.
sfa
Core data doesn't have any kind of timeout. But, if your network operations are deleting objects from the context, then the objects stored in just an ordinary (non-core-data) array could become invalid. In any case, you need to run a fetch over again each time another source makes changes to the context. If you fully implement a NSFetchedResultsController's delegate protocol you can trigger that automatically.
TechZen
You might try disabling the network operations on the device and then try to trigger the error. If you can't that would confirm the source of the problem.
TechZen
disabling the network on the device does not help :-s it comes back to the previous screen without any problem :( I'm going to change to the normal NSObject for all the items instead of a core data managed objects and see if it still exists. I'll let you know the result.
sfa
If disabling the networking prevents the crash then you should look at the parts of the code where the network data is inserted into the context.
TechZen
it's my fault, each time the view is disappearing, I delete the old items created in this step, and as a result, when coming back to the view, the items are not there. But because I use navigation controller, so when comes back to the previous steps within a small time limit, the caches for these items are still being used, while for a bigger time limit, it tries to load again from these items, they are already being cleared from the Core Data. Thanks for your hints Techzen.
sfa