The subclass of NSIncrementalStore causes infinite recursion after iOS upgrade

Originator:ysirko
Number:rdar://123453467 Date Originated:15 August, 2019
Status:New Resolved:
Product:Core Data Product Version:iOS 13 beta 6
Classification:Bug Reproducible:YES
 
When calling metadataForPersistentStoreOfType:URL:error: to get metadata for custom NSIncrementalStore, the method causes an infinite loop.

Inside subclass of NSIncrementalStore I have code like this:

- (BOOL)loadMetadata:(NSError *__autoreleasing *)error {
    NSURL *storeURL = [self URL];

    NSDictionary *metadata = @{NSStoreUUIDKey: <UUID>,
                               NSStoreTypeKey: @"MyIncrementalStore"};
    [self setMetadata:metadata];

    return YES;
}

It seems that setMetadata: method calls loadMetadata: and it creates an infinite recursion(see screenshots).

https://www.dropbox.com/s/hj2nl3oenm5ycly/app%20crash.png?dl=0 https://www.dropbox.com/s/ze56t153jlvx1lc/Screen%20Shot%202019-08-22%20at%2010.44.40%20AM.png?dl=0

I've noticed it only after upgrade from iOS 13 beta 4 to iOS beta 6. The bug isn't reproducible on older iOS versions and on freshly installed apps.

Appleā€™s documentation also suggests the same approach at https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/IncrementalStorePG/ImplementationStrategy/ImplementationStrategy.html#//apple_ref/doc/uid/TP40010706-CH2-SW2

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!