Crash in UITableView after update on iOS 11 beta

Originator:konstantin
Number:rdar://33179382 Date Originated:07-Juli-2017 01:50 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 11.0 (15A5304f)
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
Updating a table view with beginUpdates/endUpdates and deleteRowsAtIndexPaths in between crashes on iOS 11 beta.

Steps to Reproduce:
1. Open attached example project in Xcode 9 beta
2. Build & Run on iOS 11 beta simulator
3. Tap Edit
4. Delete a row
5. Crash


Expected Results:
This should not crash, works properly on iOS 10.

Actual Results:
Crashes with an internal inconsistency exception that isn't correct, i.e. we never return 2 when asked for number of items, yet the exception says so:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0.  The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010e19779b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010daf9121 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010e19c852 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x000000010d5a8612 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
	4   UIKit                               0x000000010e72e9f1 -[UITableView _endCellAnimationsWithContext:] + 17773
	5   ExceptionInTableViewAfterUpdateOniOS11 0x000000010d1eaee1 -[ViewController tableView:commitEditingStyle:forRowAtIndexPath:] + 513
	6   UIKit                               0x000000010e76b2d3 -[UITableView _animateDeletionOfRowAtIndexPath:] + 177
	7   UIKit                               0x000000010e773e53 __82-[UITableView _contextualActionForDeletingRowAtIndexPath:usingPresentationValues:]_block_invoke + 59
	8   UIKit                               0x000000010ec79c2b -[UIContextualAction executeHandlerWithView:completionHandler:] + 174
	9   UIKit                               0x000000010ef4c3f3 -[UISwipeOccurrence _performSwipeAction:inPullview:swipeInfo:] + 696
	10  UIKit                               0x000000010ef4dbea -[UISwipeOccurrence swipeActionPullView:tappedAction:] + 112
	11  UIKit                               0x000000010f0250a8 -[UISwipeActionPullView _tappedButton:] + 138
	12  UIKit                               0x000000010e617d45 -[UIApplication sendAction:to:from:forEvent:] + 83
	13  UIKit                               0x000000010e786c16 -[UIControl sendAction:to:forEvent:] + 67
	14  UIKit                               0x000000010e786f33 -[UIControl _sendActionsForEvents:withEvent:] + 450
	15  UIKit                               0x000000010e785e60 -[UIControl touchesEnded:withEvent:] + 618
	16  UIKit                               0x000000010ebc937e _UIGestureEnvironmentSortAndSendDelayedTouches + 5560
	17  UIKit                               0x000000010ebc3247 _UIGestureEnvironmentUpdate + 1424
	18  UIKit                               0x000000010ebc2c6b -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
	19  UIKit                               0x000000010ebc1d17 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 288
	20  UIKit                               0x000000010e68c032 -[UIWindow sendEvent:] + 4102
	21  UIKit                               0x000000010e632aae -[UIApplication sendEvent:] + 352
	22  UIKit                               0x0000000127cca030 -[UIApplicationAccessibility sendEvent:] + 85
	23  UIKit                               0x000000010ef231ff __dispatchPreprocessedEventFromEventQueue + 2809
	24  UIKit                               0x000000010ef25d66 __handleEventQueueInternal + 5957
	25  CoreFoundation                      0x000000010e13ae71 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	26  CoreFoundation                      0x000000010e11f56f __CFRunLoopDoSources0 + 271
	27  CoreFoundation                      0x000000010e11eb1f __CFRunLoopRun + 1039
	28  CoreFoundation                      0x000000010e11e499 CFRunLoopRunSpecific + 409
	29  GraphicsServices                    0x0000000112f309d7 GSEventRunModal + 62
	30  UIKit                               0x000000010e6160b8 UIApplicationMain + 159
	31  ExceptionInTableViewAfterUpdateOniOS11 0x000000010d1eb30f main + 111
	32  libdyld.dylib                       0x0000000111a74771 start + 1
	33  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException


Version:
iOS 11.0 (15A5304f)

Notes:

Comments

Link to sample project

https://github.com/PSPDFKit-labs/radar.apple.com/tree/master/33179382%20-%20Crash%20in%20UITableView%20after%20update%20on%20iOS%2011%20beta


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!