NSIndexSet Concurrent Enumeration Incorrect

I'm not sure if this is a recent issue, but I discovered NSIndexSet concurrency has a bug where not all indexes are enumerated.

The following is a small sample demonstrating the issue in ObjC:

NSLog(@"Hello, World! %@", NSProcessInfo.processInfo.operatingSystemVersionString);
for (NSUInteger i = 0, n = 10; i < n; i++) {
    NSUInteger total = 301;
    NSMutableIndexSet *all = [NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(0, total)];
    NSIndexSet *pass = [all indexesWithOptions:NSEnumerationConcurrent passingTest:^BOOL(NSUInteger idx, BOOL *stop) {
        return true;
    }];
    NSCAssert(all.count == pass.count, @"Mismatch #%ld %ld != %ld", i, all.count, pass.count);
}

Results on Version 26.4 (Build 25E246) look like Mismatch #0 297 != 301

Disabling concurrency (options:0) is a workaround.

Feedback FB22447001

NSIndexSet Concurrent Enumeration Incorrect
 
 
Q