UITableView batch updates crash when inserting a section and row in that section

Originator:jasongregori
Number:rdar://7283551 Date Originated:2009 09 07
Status:open Resolved:
Product:iPhone SDK Product Version:3.0
Classification:Crash/Hang/Data Loss Reproducible:always
 
07-Oct-2009 09:55 AM Jason Gregori:
Summary:
If you do a batch update to a UITableView that inserts a section then inserts more than 1 row into that section, UITableView crashes on endUpdates. This KIND OF makes sense, but a big problem is that NSFetchedResultsController does and advises this when changing content.

Steps to Reproduce:
1. UITableView beginUpdates
2. Insert a section.
3. Insert more than 1 row into that section.
4. UITableView endUpdates.
5. CRASH

Expected Results:
No crash, update like normal.

Actual Results:
CRASH.

Regression:
It occurs always.

Notes:
A work around is to keep track of what sections you've added and not insert rows for those sections. However, since I don't know exactly what's going on in your code, I don't know if that covers the entire bug.


I've included a sample project.


Crash Backtrace:
#0  0x302ac924 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ ()
#1  0x95ff1e3b in objc_exception_throw ()
#2  0x3028e5fb in +[NSException raise:format:arguments:] ()
#3  0x3028e55a in +[NSException raise:format:] ()
#4  0x305684e9 in _NSArrayRaiseBoundException ()
#5  0x30505a47 in -[NSCFArray objectAtIndex:] ()
#6  0x3094b807 in -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] ()
#7  0x3094065b in -[UITableView endUpdates] ()


'UITableView Insert Row Bug.zip' and 'Jason-Gregoris-iMac.spx' were successfully uploaded

07-Oct-2009 10:05 AM Jason Gregori:
UPDATE: It looks like the crash only happens if the inserted section is the last section in the tableView.

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!