Endless Hang on Saving a Core Data Document
-
Hi, all,
I made a discovery today: a program of mine, which has multiple
document types, freezes upon saving for a second time after changes
have been made (following a first save). I tried interrupting using
GDB, and I also tried using Spin Control. Below is (what I think is
relevant) from what Spin Control displayed.
* Details of a common example: My program maintains a list of entries
in a table view using Core Data entities in an NSArrayController
subclass. If after my first save I add an entry and then delete it,
my program will save again without freezing. If I add one and do not
delete it, it will cause a freeze-up.
A search for the words "core," "data," and "hang" yielded an
interesting discussion on saving to a persistent store, but failed to
find anything that I thought was relevant to my situation.
I am using Leopard and Xcode 3. I would be happy to post relevant
code, if only I knew what code (out of more than eighty files) to
post. This problem may very well be with my code, but I have no clue
where to look. Basically, I suppose that I'm asking: what sort of
programming error would yield a hang involving a call to -
[NSSQLiteConnection execute] (as you might see below)? My actions
before the hang involve new items being added through -
[NSArrayController add:].
Any ideas would be helpful!
Cheers,
Andrew
Call graph:
742 Thread_4d03
742 start
742 main
742 NSApplicationMain
742 -[NSApplication run]
742 -[NSApplication sendEvent:]
742 -[NSApplication _handleKeyEquivalent:]
742 -[NSMenu performKeyEquivalent:]
742 -[NSCarbonMenuImpl
performActionWithHighlightingForItemAtIndex:]
742 -[NSMenu performActionForItemAtIndex:]
742 -[NSApplication sendAction:to:from:]
742 -[NSDocument
saveDocumentWithDelegate:didSaveSelector:contextInfo:]
742 -[NSDocument
saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:]
742 -[NSDocument
_saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo
:]
742 -[NSDocument
saveToURL:ofType:forSaveOperation:error:]
742 -[NSPersistentDocument
writeSafelyToURL:ofType:forSaveOperation:error:]
742 -[DLBasicDocument
writeToURL:ofType:forSaveOperation:originalContentsURL:error:]
742 -[NSPersistentDocument
writeToURL:ofType:forSaveOperation:originalContentsURL:error:]
742 -[NSManagedObjectContext
save:]
742 -
[NSPersistentStoreCoordinator(_NSInternalMethods)
executeRequest:withContext:]
742 -[NSSQLCore
executeRequest:withContext:]
742 -[NSSQLCore
saveChanges:]
742 -[NSSQLCore
performChanges]
742 -[NSSQLCore
_performChangesWithAdapterOps:]
742 -
[NSSQLConnection performAdapterOperations:]
742 -
[NSSQLiteConnection insertRow:]
742 -
[NSSQLiteConnection execute]
742 _execute
482 usleep
$UNIX2003
482
nanosleep$UNIX2003
482
__semwait_signal
482
__semwait_signal
260
sqlite3_step -
As an important note, I decided to try changing from an SQLite store
to an XML store. No more crashing!
I'd really like to use SQLite, though, in this program. I have no
clue where to look for info on SQLite compatibility with particular
types of data, though, if that is indeed the issue. If I missed a
document, I'd love to have a link. :)
Cheers,
Andrew
On Feb 27, 2008, at 8:15 PM, Andrew Merenbach wrote:> Hi, all,
>
> I made a discovery today: a program of mine, which has multiple
> document types, freezes upon saving for a second time after changes
> have been made (following a first save). I tried interrupting using
> GDB, and I also tried using Spin Control. Below is (what I think is
> relevant) from what Spin Control displayed.
>
> * Details of a common example: My program maintains a list of
> entries in a table view using Core Data entities in an
> NSArrayController subclass. If after my first save I add an entry
> and then delete it, my program will save again without freezing. If
> I add one and do not delete it, it will cause a freeze-up.
>
> A search for the words "core," "data," and "hang" yielded an
> interesting discussion on saving to a persistent store, but failed
> to find anything that I thought was relevant to my situation.
>
> I am using Leopard and Xcode 3. I would be happy to post relevant
> code, if only I knew what code (out of more than eighty files) to
> post. This problem may very well be with my code, but I have no
> clue where to look. Basically, I suppose that I'm asking: what sort
> of programming error would yield a hang involving a call to -
> [NSSQLiteConnection execute] (as you might see below)? My actions
> before the hang involve new items being added through -
> [NSArrayController add:].
>
> Any ideas would be helpful!
>
> Cheers,
> Andrew
>
> Call graph:
> 742 Thread_4d03
> 742 start
> 742 main
> 742 NSApplicationMain
> 742 -[NSApplication run]
> 742 -[NSApplication sendEvent:]
> 742 -[NSApplication _handleKeyEquivalent:]
> 742 -[NSMenu performKeyEquivalent:]
> 742 -[NSCarbonMenuImpl
> performActionWithHighlightingForItemAtIndex:]
> 742 -[NSMenu performActionForItemAtIndex:]
> 742 -[NSApplication sendAction:to:from:]
> 742 -[NSDocument
> saveDocumentWithDelegate:didSaveSelector:contextInfo:]
> 742 -[NSDocument
> saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo
> :]
> 742 -[NSDocument
> _saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo
> :]
> 742 -[NSDocument
> saveToURL:ofType:forSaveOperation:error:]
> 742 -[NSPersistentDocument
> writeSafelyToURL:ofType:forSaveOperation:error:]
> 742 -[DLBasicDocument
> writeToURL:ofType:forSaveOperation:originalContentsURL:error:]
> 742 -[NSPersistentDocument
> writeToURL:ofType:forSaveOperation:originalContentsURL:error:]
> 742 -[NSManagedObjectContext
> save:]
> 742 -
> [NSPersistentStoreCoordinator(_NSInternalMethods)
> executeRequest:withContext:]
> 742 -[NSSQLCore
> executeRequest:withContext:]
> 742 -[NSSQLCore
> saveChanges:]
> 742 -[NSSQLCore
> performChanges]
> 742 -[NSSQLCore
> _performChangesWithAdapterOps:]
> 742 -
> [NSSQLConnection performAdapterOperations:]
> 742 -
> [NSSQLiteConnection insertRow:]
> 742 -
> [NSSQLiteConnection execute]
> 742 _execute
> 482 usleep
> $UNIX2003
> 482
> nanosleep$UNIX2003
> 482
> __semwait_signal
> 482
> __semwait_signal
> 260
> sqlite3_step -
Andrew,
There's a known issue on the current Leopard using
NSPersistentDocument with an SQLite store under Garbage Collection.
Change any one of the 3 pieces in that configuration and things will
work fine. We will be addressing the issue.
--
-Ben -
Hi,
We have a Core Data/ Leopard/Garbage collection/SQLite application
that is never returning from save. I found your post, and changing to
XML did solve the issue.
Is there a rdar for this? We do have a 100% repro case, and we'd like
to use SQLite...
Thanks!
Mathieu
On 28-Feb-08, at 3:32 PM, Ben Trumbull wrote:> Andrew,
>
> There's a known issue on the current Leopard using
> NSPersistentDocument with an SQLite store under Garbage Collection.
> Change any one of the 3 pieces in that configuration and things will
> work fine. We will be addressing the issue.
> --
>
> -Ben
> -
Oh, yeah, this was my issue, right? For some stupid reason, I never
filed a bug report. Strange that this hasn't been addressed yet in a
dot update -- it seems pretty significant. Of course, there's a lot
to do for future OSes, I suppose. Also strange that we don't see this
issue come up more often in the archives... I would've thought that CD
+ SQLite + Garbage Collection would be a very popular combination.
Just to be sure that it hasn't been fixed (since I don't have a test
case handy), you're using 10.5.5 and not an earlier Leopard?
I encourage you very strongly to file a bug report; if I can find the
time to detail the issue in clear and concise terms, I will do the
same at some point.
Best,
Andrew
On Nov 4, 2008, at 7:52 AM, Mathieu Coursolle wrote:> Hi,
>
> We have a Core Data/ Leopard/Garbage collection/SQLite application
> that is never returning from save. I found your post, and changing
> to XML did solve the issue.
>
> Is there a rdar for this? We do have a 100% repro case, and we'd
> like to use SQLite...
>
> Thanks!
>
> Mathieu
>
> On 28-Feb-08, at 3:32 PM, Ben Trumbull wrote:
>
>> Andrew,
>>
>> There's a known issue on the current Leopard using
>> NSPersistentDocument with an SQLite store under Garbage Collection.
>> Change any one of the 3 pieces in that configuration and things
>> will work fine. We will be addressing the issue.
>> --
>>
>> -Ben
>>
>


