• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: problem unit testing core data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem unit testing core data


  • Subject: Re: problem unit testing core data
  • From: Matthew Firlik <email@hidden>
  • Date: Wed, 26 Oct 2005 11:18:38 -0700


On Oct 26, 2005, at 7:51 AM, Jesse Grosjean wrote:

I'm seeing the following error when I run unit tests on my NSPersistentDocument based application:

2005-10-26 08:53:18.068 otest[19257] *** -[NSAutoreleasePool dealloc]: Exception ignored while releasing an object in an autorelease pool: The NSManagedObject with ID:0x346e060 <x- coredata://FD637DAE-68F9-4B0B-BC4F-7646659C9C4A/ContentIndex/p114> has been invalidated.

The error occurs after running each test case as the auto-release pool for that test case is released, then the otest tool crashes after running all of the tests. Here's some more notes on what's going on, please let me know if you have ideas on where I'm going wrong or thoughts on getting around the problem.

[snip]

The exception is thrown as the managed object context is being dealloced (maybe somewhere in the private _dispose: method). It's important to note that when I run my application normally I see no errors when opening and closing documents and ObjectAlloc shows that objects are being created and released as expected.

The exception is thrown not from a managed object context, but from a managed object which is attempting to fulfill its fault. When a context is reset or disposed (deallocated), all of the objects currently registered in the context are converted back to faults (in this case rendering them into an invalid state, at least in terms of access to persistent data.) If you happen to have a reference to one of these objects and attempt to access any persisted values, you'll see the above exception. (Note this is different than the 'could not fulfill fault' exception some might see: that is a case where the framework cannot resolve a (seemingly) valid fault. In this case, the framework knows specifically the fault is invalid -- because of the change in the state of the related context -- and shouldn't be used.)


You might want to implement and/or put a breakpoint in the didTurnIntoFault method on your managed object subclass: this method will be called on each object invalidated in the context (as a result of the deallocation), and you should be able to see all of the "ContextIndex" objects which are going to be tossed. (You could try logging all of the object IDs and something more meaningful, to then correlate against the ID information in the exception later to get a better idea of which one is being accessed, and then why ...)

- matthew

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >problem unit testing core data (From: Jesse Grosjean <email@hidden>)

  • Prev by Date: Re: Using an NSString as standard input to an NSTask
  • Next by Date: How to receive notifications while in modal loop?
  • Previous by thread: Re: problem unit testing core data
  • Next by thread: Re: problem unit testing core data
  • Index(es):
    • Date
    • Thread