Crash invalidates url for NSPersistentStoreCoordinator

0

I have a Core Data app that has a bug that causes the app to crash and I have not tracked down its cause yet. One of the results of the crash is that the next time the app is started up it can not open the persistent store used by the application previously. The following error is returned from the addPersistentStoreWithType: method:

NSUnderlyingException = Error validating url for store;

And, of course, it cannot retrieve any of the objects previously stored by the app. Does anyone know what can cause an app to no longer be able to find its persistent store?

The crash that causes the app to shut down prior to all this happening produces the following crash log:

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

Thread 0 Crashed:
0   libSystem.B.dylib              0x0007e98c __kill + 8
1   libSystem.B.dylib              0x0007e97c kill + 4
2   libSystem.B.dylib              0x0007e96e raise + 10
3   libSystem.B.dylib              0x0009361a abort + 34
4   libstdc++.6.dylib              0x000453b0 __gnu_cxx::__verbose_terminate_handler() + 376
5   libobjc.A.dylib                0x00005858 _objc_terminate + 104
6   libstdc++.6.dylib              0x00043776 __cxxabiv1::__terminate(void (*)()) + 46
7   libstdc++.6.dylib              0x000437ca std::terminate() + 10
8   libstdc++.6.dylib              0x00043896 __cxa_throw + 74
9   libobjc.A.dylib                0x00004714 objc_exception_throw + 64
10  Foundation                     0x000013c2 __NSThreadPerformPerform + 570
11  CoreFoundation                 0x00056a96 CFRunLoopRunSpecific + 1834
12  CoreFoundation                 0x00056356 CFRunLoopRunInMode + 42
13  GraphicsServices               0x00003b2c GSEventRunModal + 108
14  GraphicsServices               0x00003bd8 GSEventRun + 56
15  UIKit                          0x00002768 -[UIApplication _run] + 384
16  UIKit                          0x0000146c UIApplicationMain + 688
17  Meetchu                        0x00002568 main (main.m:14)
18  Meetchu                        0x0000251c start + 32

I cannot figure out what is happening from this information. Can anyone help with either of these errors?

Many thanks in advance.

iphone
cocoa
cocoa-touch
core-data
nserror
asked on Stack Overflow Jul 6, 2010 by Drew C

2 Answers

1

If you're storing the actual URL to a file in the app's directory instead of regenerating it each time relative to the app directory, then the invalid URL is the result of the simulator/device changing the name of the app directory to a random UUID. It does that sometimes in response to crashes.

The obvious first step is the log the URL and see if the store is actually at that location.

answered on Stack Overflow Jul 6, 2010 by TechZen
0

Drew,

Without seeing some code, I can tell you that one source of agony to me when I first started with Core Data was versioning your models. If you have changed your managed object model in any way, this will cause your app to crash without some versioning (i.e., lightweight) code in place.

This may not be the source of your problem, but one thing you can try is to either remove your app from your iPhone Simulator or use "Reset Contents and Settings" from the iPhone simulator menu. If this fixes the problem, then you're looking at a migrations issue.

Cheers.

answered on Stack Overflow Jul 6, 2010 by Neal L

User contributions licensed under CC BY-SA 3.0