title: Core Data EXC_BAD_ACCESS KERN_PROTECTION_FAILURE
body: <p>I have multiple crash reports that point to the following:</p>
  
  <pre><code>Thread : Crashed: NSOperationQueue 0x18c7fba0
  0  libsystem_platform.dylib       0x38665a36 OSAtomicCompareAndSwap32Barrier + 13
  1  libobjc.A.dylib                0x3805694b realizeClass(objc_class*) + 78
  2  libobjc.A.dylib                0x38058797 lookUpImpOrForward + 74
  3  libobjc.A.dylib                0x3805102b _class_lookupMethodAndLoadCache3 + 34
  4  libobjc.A.dylib                0x38050df9 _objc_msgSend_uncached + 24
  5  CoreData                       0x2da7b5bb -[_NSFaultingMutableSet copyWithZone:] + 238
  6  MyApp                          0x0027226f -[Zoo getSortedCats] (Zoo.m:63)
  7  MyApp                          0x00286955 -[BlockExecutionOperation main] (BlockExecutionOperation.m:30)
  8  Foundation                     0x2e627aa5 -[__NSOperationInternal _start:] + 772
  9  Foundation                     0x2e6cb96d __NSOQSchedule_f + 60
  10 libdispatch.dylib              0x3853e4b7 _dispatch_async_redirect_invoke + 110
  11 libdispatch.dylib              0x3853f7d9 _dispatch_root_queue_drain + 224
  12 libdispatch.dylib              0x3853f9c5 _dispatch_worker_thread2 + 56
  13 libsystem_pthread.dylib        0x38669dff _pthread_wqthread + 298
  </code></pre>
  
  <p>The getSortedCats method looks like this:</p>
  
  <pre><code>- (NSArray *)getSortedCats {
      NSSet* cats = [self.cats copy]; //this is line 63, where the crash occurs
  
      //do some sorting
  
      return sortedCats;
  
  }
  </code></pre>
  
  <p>And Zoo is an NSManagedObject subclass with a cats property:</p>
  
  <pre><code>@property (atomic, retain) NSSet *cats;
  </code></pre>
  
  <p>So why the crash on the self.cats line? What does this error mean? How to avoid? It only happens once in a while, and is not reproducible.</p>