[Leopard] CoreData fails to save, fails to report error

  • Hi!

    I am having a problem where my CoreData document fails to save. The
    problem is most certainly of my making, as it just cropped up.

    Trouble is that I can't make much sense of it because CoreData seems
    to fail at creating the error message:

    *** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
    (key: NSLocalizedDescription)

    #0  0x909794b6 in -[NSCFDictionary setObject:forKey:] ()
    #1  0x96d1263d in -[NSManagedObject(_NSInternalMethods)
    _generateErrorWithCode:andMessage:forKey:andValue:additionalDetail:] ()
    #2  0x96cbe98e in -[NSRelationshipDescription(_NSInternalMethods)
    _nonPredicateValidateValue:forKey:inObject:error:] ()
    #3  0x96cbdcce in -[NSManagedObject(_NSInternalMethods)
    _validateValue:forProperty:andKey:withIndex:error:] ()
    #4  0x96cbd9dd in -[NSManagedObject(_NSInternalMethods)
    _validatePropertiesWithError:] ()
    #5  0x96cbd80b in -[NSManagedObject(_NSInternalMethods)
    _validateForSave:] ()
    #6  0x96cbd600 in -[NSManagedObjectContext(_NSInternalAdditions)
    _validateObjects:forOperation:error:exhaustive:forSave:] ()
    #7  0x96cbd04f in -[NSManagedObjectContext(_NSInternalAdditions)
    _validateChangesForSave:] ()
    #8  0x96cbcd52 in -
    [NSManagedObjectContext(_NSInternalChangeProcessing)
    _prepareForPushChanges:] ()
    #9  0x96cbc5f6 in -[NSManagedObjectContext save:] ()
    #10 0x91693a8a in -[NSPersistentDocument
    writeToURL:ofType:forSaveOperation:originalContentsURL:error:] ()
    #11 0x0000f0a7 in -[Document
    writeToURL:ofType:forSaveOperation:originalContentsURL:error:] ()
    #12 0x91489635 in -[NSDocument
    _writeSafelyToURL:ofType:forSaveOperation:error:] ()
    #13 0x914894f8 in -[NSDocument
    writeSafelyToURL:ofType:forSaveOperation:error:] ()
    #14 0x91693e49 in -[NSPersistentDocument
    writeSafelyToURL:ofType:forSaveOperation:error:] ()
    #15 0x91488f87 in -[NSDocument
    saveToURL:ofType:forSaveOperation:error:] ()
    #16 0x0000f054 in -[Document saveToURL:ofType:forSaveOperation:error:]
    ()
    #17 0x91488c10 in -[NSDocument
    _saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo
    :] ()
    #18 0x91488bc1 in -[NSDocument
    saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo
    :] ()
    #19 0x914887f6 in -[NSDocument
    _savePanelWasPresented:withResult:inContext:] ()
    #20 0x9148850a in -[NSSavePanel(NSSavePanelRuntime)
    _didEndSheet:returnCode:contextInfo:] ()
    #21 0x91290b8c in -[NSApplication endSheet:returnCode:] ()
    #22 0x913dab39 in -[NSSavePanel(NSSavePanelRuntime) dismissWindow:] ()
    #23 0x913da9f5 in -[NSSavePanel(NSSavePanelRuntime) ok:] ()
    #24 0x9124ef94 in -[NSApplication sendAction:to:from:] ()
    #25 0x9124eed4 in -[NSControl sendAction:to:] ()
    #26 0x9124ed5a in -[NSCell _sendActionFrom:] ()
    #27 0x9124e3bb in -[NSCell trackMouse:inRect:ofView:untilMouseUp:] ()
    #28 0x9124dc12 in -[NSButtonCell
    trackMouse:inRect:ofView:untilMouseUp:] ()
    #29 0x9124d4cc in -[NSControl mouseDown:] ()
    #30 0x9124bd9b in -[NSWindow sendEvent:] ()
    #31 0x91218a2c in -[NSApplication sendEvent:] ()
    #32 0x91176705 in -[NSApplication run] ()
    #33 0x911439ba in NSApplicationMain ()
    #34 0x00001f8a in start ()

    Do I have any chance to figure out what is going wrong here?

    Pierre

    ---
    Pierre Bernard
    http://www.bernard-web.com/pierre
    http://www.houdah.com
  • OK, I found the bug on my end: I forgot to cascade a deletion. Thus I
    had objects with dangling reverse relationships.

    What remains is a CoreData bug in reporting the error.

    BTW, this is how I tracked the error:

    @interface NSManagedObject (Houdah)

    - (BOOL)_validateValue:(id *)fp8 forProperty:(id)fp12 andKey:(id)fp16
    withIndex:(unsigned int)fp20 error:(id *)fp24;

    @end

    @implementation ManagedObject

    - (BOOL)_validateValue:(id *)fp8 forProperty:(id)fp12 andKey:(id)fp16
    withIndex:(unsigned int)fp20 error:(id *)fp24
    {
    MLogString(@"class name: %@", [self className]);
    MLogString(@"value: %@", *fp8);
    MLogString(@"property: %@", fp12);
    MLogString(@"key: %@", fp16);
    MLogString(@"index: %i", fp20);

    return [super _validateValue:fp8 forProperty:fp12 andKey:fp16
    withIndex:fp20 error:fp24];
    }

    @end

    Pierre

    On Nov 10, 2007, at 11:01 PM, Pierre Bernard wrote:

    > Hi!
    >
    > I am having a problem where my CoreData document fails to save. The
    > problem is most certainly of my making, as it just cropped up.
    >
    > Trouble is that I can't make much sense of it because CoreData seems
    > to fail at creating the error message:
    >
    > *** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
    > (key: NSLocalizedDescription)
    >
    > #0  0x909794b6 in -[NSCFDictionary setObject:forKey:] ()
    > #1  0x96d1263d in -[NSManagedObject(_NSInternalMethods)
    > _generateErrorWithCode:andMessage:forKey:andValue:additionalDetail:]
    > ()
    > #2  0x96cbe98e in -[NSRelationshipDescription(_NSInternalMethods)
    > _nonPredicateValidateValue:forKey:inObject:error:] ()
    > #3  0x96cbdcce in -[NSManagedObject(_NSInternalMethods)
    > _validateValue:forProperty:andKey:withIndex:error:] ()
    > #4  0x96cbd9dd in -[NSManagedObject(_NSInternalMethods)
    > _validatePropertiesWithError:] ()
    > #5  0x96cbd80b in -[NSManagedObject(_NSInternalMethods)
    > _validateForSave:] ()
    > #6  0x96cbd600 in -[NSManagedObjectContext(_NSInternalAdditions)
    > _validateObjects:forOperation:error:exhaustive:forSave:] ()
    > #7  0x96cbd04f in -[NSManagedObjectContext(_NSInternalAdditions)
    > _validateChangesForSave:] ()
    > #8  0x96cbcd52 in -
    > [NSManagedObjectContext(_NSInternalChangeProcessing)
    > _prepareForPushChanges:] ()
    > #9  0x96cbc5f6 in -[NSManagedObjectContext save:] ()
    > #10 0x91693a8a in -[NSPersistentDocument
    > writeToURL:ofType:forSaveOperation:originalContentsURL:error:] ()
    > #11 0x0000f0a7 in -[Document
    > writeToURL:ofType:forSaveOperation:originalContentsURL:error:] ()
    > #12 0x91489635 in -[NSDocument
    > _writeSafelyToURL:ofType:forSaveOperation:error:] ()
    > #13 0x914894f8 in -[NSDocument
    > writeSafelyToURL:ofType:forSaveOperation:error:] ()
    > #14 0x91693e49 in -[NSPersistentDocument
    > writeSafelyToURL:ofType:forSaveOperation:error:] ()
    > #15 0x91488f87 in -[NSDocument
    > saveToURL:ofType:forSaveOperation:error:] ()
    > #16 0x0000f054 in -[Document
    > saveToURL:ofType:forSaveOperation:error:] ()
    > #17 0x91488c10 in -[NSDocument
    > _saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo
    > :] ()
    > #18 0x91488bc1 in -[NSDocument
    > saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo
    > :] ()
    > #19 0x914887f6 in -[NSDocument
    > _savePanelWasPresented:withResult:inContext:] ()
    > #20 0x9148850a in -[NSSavePanel(NSSavePanelRuntime)
    > _didEndSheet:returnCode:contextInfo:] ()
    > #21 0x91290b8c in -[NSApplication endSheet:returnCode:] ()
    > #22 0x913dab39 in -[NSSavePanel(NSSavePanelRuntime) dismissWindow:] ()
    > #23 0x913da9f5 in -[NSSavePanel(NSSavePanelRuntime) ok:] ()
    > #24 0x9124ef94 in -[NSApplication sendAction:to:from:] ()
    > #25 0x9124eed4 in -[NSControl sendAction:to:] ()
    > #26 0x9124ed5a in -[NSCell _sendActionFrom:] ()
    > #27 0x9124e3bb in -[NSCell trackMouse:inRect:ofView:untilMouseUp:] ()
    > #28 0x9124dc12 in -[NSButtonCell
    > trackMouse:inRect:ofView:untilMouseUp:] ()
    > #29 0x9124d4cc in -[NSControl mouseDown:] ()
    > #30 0x9124bd9b in -[NSWindow sendEvent:] ()
    > #31 0x91218a2c in -[NSApplication sendEvent:] ()
    > #32 0x91176705 in -[NSApplication run] ()
    > #33 0x911439ba in NSApplicationMain ()
    > #34 0x00001f8a in start ()
    >
    >
    > Do I have any chance to figure out what is going wrong here?
    >
    > Pierre
    >
    > ---
    > Pierre Bernard
    > http://www.bernard-web.com/pierre
    > http://www.houdah.com

    ---
    Pierre Bernard
    http://www.bernard-web.com/pierre
    http://www.houdah.com
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today