Core Data: Validation Error with userInfo NSDetailedErrorsKey immutable array causes crash
| Originator: | quellish | ||
| Number: | rdar://17800739 | Date Originated: | Thu, 24 Jul 2014 21:29:19 GMT |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 7.1 (11D167) |
| Classification: | Crash | Reproducible: | Always |
Summary: A key-value validation method on an NSManagedObject that returns an error with the userInfo dictionary containing an immutable value for the key NSDetailedErrorsKey will reliably crash. A mutable value will not crash. Steps to Reproduce: Steps to Reproduce: 1. Create a new Core Data application with data model, etc. 2. Add a validation method to a NSManagedObject subclass 3. Have that method return an NSError with a userInfo dictionary having an immutable array of detailed errors as the value for the key NSDetailedErrorsKey 4. Call validateForInsert:, save:, etc (any method that will invoke validation) on the context. Expected Results: Validation and error reporting should proceed normally Actual Results: CoreData calls addObject on the immutable array, resulting in a crash with the following stack trace: <unknown>:0: error: -[ValidationTestCase testMultiValidationThreadConfinement] : failed: caught "NSInvalidArgumentException", "-[__NSArrayI addObject:]: unrecognized selector sent to instance 0x7a773940" ( 0 CoreFoundation 0x006c91e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x004458e5 objc_exception_throw + 44 2 CoreFoundation 0x00766243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275 3 CoreFoundation 0x006b950b ___forwarding___ + 1019 4 CoreFoundation 0x006b90ee _CF_forwarding_prep_0 + 14 5 CoreData 0x04f40d87 -[NSManagedObject(_NSInternalMethods) _chainNewError:toOriginalErrorDoublePointer:] + 247 6 CoreData 0x04eaf6bb -[NSManagedObject(_NSInternalMethods) _validateValue:forProperty:andKey:withIndex:error:] + 427 7 CoreData 0x04eaf402 -[NSManagedObject(_NSInternalMethods) _validatePropertiesWithError:] + 354 8 CoreData 0x04eaf281 -[NSManagedObject(_NSInternalMethods) _validateForSave:] + 113 9 CoreData 0x04eca55d -[NSManagedObject validateForInsert:] + 77 10 ValidationTests 0x03f2cdcc -[ValidationTestCase testMultiValidationThreadConfinement] + 684 Version: 7.1 (11D167) Notes: Sample project demonstrating this with tests will be uploaded shortly. Making the array of detailed errors mutable prevents the crash. No documentation indicates that the array is expected to be mutable, and it seems unlikely that this requires a mutable object by design. Configuration: iPhone 5s, iOS Simulator Attachments: 'validation.log' was successfully uploaded.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!