Inconsistent behavior on invalid collection view action, should throw NSInternalInconsistencyException

Originator:brian.nickel
Number:rdar://18104552 Date Originated:22-Aug-2014 11:39 AM
Status:Open Resolved:
Product::iOS SDK Product Version:
Classification: Reproducible:With Guard Malloc
 
Summary:
I have a collection view where I both add and move content in a batch update:

Before:
AB
CD
EF

After:
A
GBC
HDEF

I was incorrectly moving B to (1, 0) and adding at G (1, 0), which should fail.  Instead I get one of three random behaviors:

1. The step succeeds and produces an invalid animation which may not be seen offscreen.
2. The app crashes in [UICollectionView _endItemAnimations] with SIGABRT incorrect checksum for freed object - object was probably modified after being freed.
3. The app crashes in [UICollectionView _computeItemUpdates] with EXC_BAD_ACCESS.

If I turn on Guard Malloc, it will always crash on case 3.  Given the unpredictable behavior of the app on this error, and the fact the SDK appears to be writing to freed memory, the SDK should throw an NSInternalInconsistencyException here.

Steps to Reproduce:
Run attached app.

Expected Results:
NSInternalInconsistencyException, similar to other invalid batch updates

Actual Results:
Invalid animation (cells don't match final data) or memory related crash

Version:
iOS 7.1.2, 8 beta 5, simulator and device

Notes:


Configuration:
iOS simulator, iPad Air

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!