Core Data many-to-one relationships sometimes break

Originator:thedov
Number:rdar://24029100 Date Originated:31-Dec-2015 11:46 AM
Status:Open Resolved:
Product:iOS SDK Product Version:9.1
Classification:Serious Bug Reproducible:Sometimes
 
Summary:
I haven’t been able to isolate a reproducible test scenario, but sometimes, I get an error that makes no sense (it tells me that it’s expecting the very type I gave):

caught "NSInvalidArgumentException", "Unacceptable type of value for to-one relationship: property = "format"; desired type = MyModel.ViewingFormat; given type = MyModel.ViewingFormat; value = <MyModel.ViewingFormat: 0x816884b0> (entity: ViewingFormat; id: 0x8157fea0 <x-coredata:///ViewingFormat/t1CF56B58-A1AC-4C2A-879A-C1F6F0C3321116848> ; data: <fault>)."

Steps to Reproduce:
My code is in Swift. My model specifies both sides of the many-to-one relationship. I only assign the relationship using the “to-one” side of the relationship (e.g. object.format = <a single format object>).

Expected Results:
Specifying an object in a many-to-one relationship works

Actual Results:
Exception thrown during test execution, with this stack trace

(
    0   CoreFoundation                      0x00729a14 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x023dae02 objc_exception_throw + 50
    2   CoreData                            0x002a5532 _PFManagedObject_coerceValueForKeyWithDescription + 2178
    3   CoreData                            0x0027829d _sharedIMPL_setvfk_core + 205
    4   CoreData                            0x0028d937 _svfk_4 + 39
    5   MyModel                             0x0018edb9 _TFC15MyModel7ViewingcfMS0_FT7contextCSo22NSManagedObjectContext7movieIDCSo17NSManagedObjectID4dateGSqCSo6NSDate_6formatGSqSS_6ratingGSqSd_8commentsGSqSS__S0_ + 1593
    6   MyModel                             0x0018f153 _TFC15MyModel7ViewingCfMS0_FT7contextCSo22NSManagedObjectContext7movieIDCSo17NSManagedObjectID4dateGSqCSo6NSDate_6formatGSqSS_6ratingGSqSd_8commentsGSqSS__S0_ + 499
    7   MyModel                             0x0015fe01 _TFFC15MyModel18MovieViewingLoaderP33_2E4A16AF89455422C5D7DDC442A6F25E20addViewingsToLibraryFS0_FTGVSs10DictionaryVS_15MovieIdentifierCS_9MovieData_7contextCSo22NSManagedObjectContext_GSaCSo17NSManagedObjectID_U2_FVS_11ViewingDataS5_ + 737
    8   MyModel                             0x00158da0 _TPA__TFFC15MyModel18MovieViewingLoaderP33_2E4A16AF89455422C5D7DDC442A6F25E20addViewingsToLibraryFS0_FTGVSs10DictionaryVS_15MovieIdentifierCS_9MovieData_7contextCSo22NSManagedObjectContext_GSaCSo17NSManagedObjectID_U2_FVS_11ViewingDataS5_ + 64
    9   MyModel                             0x0015ffa0 _TTRXFo_oV15MyModel11ViewingData_oCSo17NSManagedObjectIDzoPSs9ErrorType__XFo_iS0__iS1_zoPS2___ + 224
    10  MyModel                             0x00158e66 _TPA__TTRXFo_oV15MyModel11ViewingData_oCSo17NSManagedObjectIDzoPSs9ErrorType__XFo_iS0__iS1_zoPS2___ + 102
    11  libswiftCore.dylib                  0x027c4a41 _TFeRq_Ss14CollectionType_SsS_3mapu__Rq_S__fq_FzFzqqq_S_9GeneratorSs13GeneratorType7Elementqd__GSaqd___ + 785
    12  MyModel                             0x001560c8 _TFC15MyModel18MovieViewingLoaderP33_2E4A16AF89455422C5D7DDC442A6F25E20addViewingsToLibraryfS0_FTGVSs10DictionaryVS_15MovieIdentifierCS_9MovieData_7contextCSo22NSManagedObjectContext_GSaCSo17NSManagedObjectID_ + 2504
    13  MyModel                             0x00156d42 _TFC15MyModel18MovieViewingLoader8loadRowsfS0_FzTGSaGVSs10DictionarySSSS__9inContextCSo22NSManagedObjectContext_T_ + 3042
    14  MyTests                             0x0d3659c9 _TFFFFFC15MyTests22MovieViewingLoaderSpec4specFS0_FT_T_U_FT_T_U0_FT_T_U2_FT_T_U_FzT_GSqP__ + 361
    15  MyTests                             0x0d34c62d _TPA__TFFFFFC15MyTests22MovieViewingLoaderSpec4specFS0_FT_T_U_FT_T_U0_FT_T_U2_FT_T_U_FzT_GSqP__ + 141
    16  Nimble                              0x0d4e6452 _TFF6Nimble15memoizedClosureurFFzT_q_FzSbq_U_FzSbQ_ + 722
    17  Nimble                              0x0d4e57dc _TPA__TFF6Nimble15memoizedClosureurFFzT_q_FzSbq_U_FzSbQ_ + 156
    18  Nimble                              0x0d4e5eef _TFV6Nimble10Expression8evaluateurfGS0_q__FzT_GSqq__ + 175
    19  Nimble                              0x0d51107f _TFF6Nimble10throwErrorFT7closureGSqFPSs9ErrorType_T___GVS_11MatcherFuncP__U_FTGVS_10ExpressionP__CS_14FailureMessage_Sb + 287
    20  Nimble                              0x0d50f233 _TPA__TFF6Nimble10throwErrorFT7closureGSqFPSs9ErrorType_T___GVS_11MatcherFuncP__U_FTGVS_10ExpressionP__CS_14FailureMessage_Sb + 99
    21  Nimble                              0x0d4ef05b _TFV6Nimble11MatcherFunc12doesNotMatchurfGS0_q__FzTGVS_10Expressionq__14failureMessageCS_14FailureMessage_Sb + 315
    22  Nimble                              0x0d4ef2e2 _TTWurGV6Nimble11MatcherFuncq__S_7MatcherS_FS1_12doesNotMatchuRq_S1__fq_FzTGVS_10Expressionqq_S1_9ValueType_14failureMessageCS_14FailureMessage_Sb + 178
    23  Nimble                              0x0d4e3af4 _TF6Nimble22expressionDoesNotMatchu0_Rq0_S_7Matcherzq_qq0_S0_9ValueType_FTGVS_10Expressionq__7matcherq0_5toNotSS11descriptionGSqSS__TSbCS_14FailureMessage_ + 724
    24  Nimble                              0x0d4e49a0 _TFV6Nimble11Expectation5toNotu__Rqd__S_7Matcherzq_qqd__S1_9ValueType_fGS0_q__FTqd__11descriptionGSqSS__T_ + 640
    25  MyTests                             0x0d3636b0 _TFFFFC15MyTests22MovieViewingLoaderSpec4specFS0_FT_T_U_FT_T_U0_FT_T_U2_FT_T_ + 2000
    26  MyTests                             0x0d34c1bd _TPA__TFFFFC15MyTests22MovieViewingLoaderSpec4specFS0_FT_T_U_FT_T_U0_FT_T_U2_FT_T_ + 61
    27  Quick                               0x0d5b6bf8 _TTRXFo__dT__XFdCb__dT__ + 40
    28  Quick                               0x0d5b37f2 _TTRXFdCb__dT__XFo__dT__ + 18
    29  Quick                               0x0d5c4b84 _TPA__TTRXFdCb__dT__XFo__dT__37 + 52
    30  Quick                               0x0d5b83c4 _TFC5Quick7Example3runfS0_FT_T_ + 1188
    31  Quick                               0x0d5b88d2 _TToFC5Quick7Example3runfS0_FT_T_ + 34
    32  Quick                               0x0d5b0270 __41+[QuickSpec addInstanceMethodForExample:]_block_invoke + 144
    33  CoreFoundation                      0x0060151d __invoking___ + 29
    34  CoreFoundation                      0x006013c6 -[NSInvocation invoke] + 342
    35  XCTest                              0x0b29e2f6 __24-[XCTestCase invokeTest]_block_invoke_2 + 174
    36  XCTest                              0x0b2db712 -[XCTestContext performInScope:] + 229
    37  XCTest                              0x0b29e23b -[XCTestCase invokeTest] + 193
    38  XCTest                              0x0b29e7f5 -[XCTestCase performTest:] + 529
    39  XCTest                              0x0b2cbd75 -[XCTest runTest] + 354
    40  XCTest                              0x0b29be94 -[XCTestSuite performTest:] + 427
    41  XCTest                              0x0b2cbd75 -[XCTest runTest] + 354
    42  XCTest                              0x0b29be94 -[XCTestSuite performTest:] + 427
    43  XCTest                              0x0b2cbd75 -[XCTest runTest] + 354
    44  XCTest                              0x0b29be94 -[XCTestSuite performTest:] + 427
    45  XCTest                              0x0b2cbd75 -[XCTest runTest] + 354
    46  XCTest                              0x0b285088 __25-[XCTestDriver _runSuite]_block_invoke + 61
    47  XCTest                              0x0b2ac62a -[XCTestObservationCenter _observeTestExecutionForBlock:] + 736
    48  XCTest                              0x0b284fad -[XCTestDriver _runSuite] + 491
    49  XCTest                              0x0b286028 -[XCTestDriver _checkForTestManager] + 318
    50  XCTest                              0x0b2864fd -[XCTestDriver runTestConfiguration:completionHandler:] + 399
    51  XCTest                              0x0b2dce0b _XCTestMain + 715
    52  IDEBundleInjection                  0x0013b658 ____XCBundleInjection_block_invoke_2 + 20
    53  CoreFoundation                      0x006436e0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 16
    54  CoreFoundation                      0x00639063 __CFRunLoopDoBlocks + 195
    55  CoreFoundation                      0x00638798 __CFRunLoopRun + 1016
    56  CoreFoundation                      0x006380e6 CFRunLoopRunSpecific + 470
    57  CoreFoundation                      0x00637efb CFRunLoopRunInMode + 123
    58  GraphicsServices                    0x05b30664 GSEventRunModal + 192
    59  GraphicsServices                    0x05b304a1 GSEventRun + 104
    60  UIKit                               0x00f0abfa UIApplicationMain + 160
    61  MyApp                               0x000d0afc main + 140
    62  libdyld.dylib                       0x03dc7a21 start + 1
)

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!