Crash when using auto-generated methods for ordered to-many relationship

Originator:tmk.szlc
Number:rdar://22177512 Date Originated:6 Aug 2015
Status:Open Resolved:
Product:Xcode Product Version:Xcode 7 beta 5
Classification:Serious Bug Reproducible:Always
 
Summary:
When using auto-generated methods for ordered relationship no matter Objective-C or Swift it causes app to crash in Xcode 7 beta 5 and with any other Xcode version which has these functionality of generating such methods for to-many ordered relationships. I think since Xcode 4/5.

Calling e.g. "add<Entity>Object" method ends up with:

2015-08-06 23:14:18.541 NewNSManagedExample[54727:3677632] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet'
*** First throw call stack:
(
	0   CoreFoundation                      0x00ea83b4 __exceptionPreprocess + 180
	1   libobjc.A.dylib                     0x005cde02 objc_exception_throw + 50
	2   CoreFoundation                      0x00dfc574 -[NSSet intersectsSet:] + 260
	3   Foundation                          0x00214756 NSKeyValueWillChangeBySetMutation + 153
	4   Foundation                          0x0017c4c7 NSKeyValueWillChange + 394
	5   Foundation                          0x0021466a -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:withSetMutation:usingObjects:] + 630
	6   CoreData                            0x00a981c6 _sharedIMPL_addObjectToSet_core + 182
	7   CoreData                            0x00a99189 __generateAccessor_block_invoke_2 + 41
	8   NewNSManagedExample                 0x000f0e80 _TFC19NewNSManagedExample11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb + 720
	9   NewNSManagedExample                 0x000f10c7 _TToFC19NewNSManagedExample11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb + 199
	10  UIKit                               0x0122e1c6 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 337
	11  UIKit                               0x0122f56c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3727
	12  UIKit                               0x01236929 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1976
	13  UIKit                               0x01259af6 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3142 + 68
	14  UIKit                               0x012336a6 -[UIApplication workspaceDidEndTransaction:] + 163
	15  FrontBoardServices                  0x03ff9ccc __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71
	16  FrontBoardServices                  0x03ff97a3 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54
	17  FrontBoardServices                  0x040171cb -[FBSSerialQueue _performNext] + 184
	18  FrontBoardServices                  0x04017602 -[FBSSerialQueue _performNextFromRunLoopSource] + 52
	19  FrontBoardServices                  0x040168fe FBSSerialQueueRunLoopSourceHandler + 33
	20  CoreFoundation                      0x00dc27af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
	21  CoreFoundation                      0x00db843b __CFRunLoopDoSources0 + 523
	22  CoreFoundation                      0x00db7858 __CFRunLoopRun + 1032
	23  CoreFoundation                      0x00db7196 CFRunLoopRunSpecific + 470
	24  CoreFoundation                      0x00db6fab CFRunLoopRunInMode + 123
	25  UIKit                               0x01232f8f -[UIApplication _run] + 540
	26  UIKit                               0x01238724 UIApplicationMain + 160
	27  NewNSManagedExample                 0x000f24dc main + 140
	28  libdyld.dylib                       0x039afa21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

The only workaround for now is to re-implement those methods of my own which I would avoid.

Steps to Reproduce:
1. Open project
2. Run it.

Expected Results:
App should not crash

Actual Results:
App crashes

Version:
Xcode 7 beta 5, 10.10.4

Notes:


Configuration:
10.10.4

Attachments:
'NewNSManagedExample.zip' 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!