Crash in -[DDTextKitOperation _addResultsToAttributes] when rapidly changing text of UITextView with data detectors enabled

Originator:daniel.eggert
Number:rdar://15512848 Date Originated:2013-11-20
Status: Resolved:
Product:iOS SDK Product Version:7.0.3
Classification:Crash Reproducible:
 
When rapidly changing the text of a UITextView that has data detectors turned on, the DataDetectorsUI ‘gets confused’ and causes a crash inside UIFoundation / Foundation.

Attached sample project will reproduce this crash 100%.

2013-11-20 12:12:38.744 DataDetectorTest[40408:70b] *** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'
*** First throw call stack:
(
	0   CoreFoundation                      0x0173b5e4 __exceptionPreprocess + 180
	1   libobjc.A.dylib                     0x014be8b6 objc_exception_throw + 44
	2   CoreFoundation                      0x0173b3bb +[NSException raise:format:] + 139
	3   Foundation                          0x010f0f62 -[NSRLEArray objectAtIndex:effectiveRange:] + 131
	4   Foundation                          0x010f2b86 -[NSConcreteMutableAttributedString addAttribute:value:range:] + 212
	5   UIFoundation                        0x02da3b82 __50-[NSConcreteTextStorage addAttribute:value:range:]_block_invoke + 156
	6   UIFoundation                        0x02da3a65 -[NSConcreteTextStorage addAttribute:value:range:] + 127
	7   DataDetectorsUI                     0x09fbe85c -[DDTextKitOperation _addResultsToAttributes] + 374
	8   DataDetectorsUI                     0x09fbea82 __46-[DDTextKitOperation doURLificationOnDocument]_block_invoke_2 + 39
	9   UIFoundation                        0x02da2190 -[NSTextStorage(ActorSupport) coordinateAccess:] + 48
	10  DataDetectorsUI                     0x09fbea54 __46-[DDTextKitOperation doURLificationOnDocument]_block_invoke + 134
	11  libdispatch.dylib                   0x01ad6440 _dispatch_barrier_sync_f_slow_invoke + 71
	12  libdispatch.dylib                   0x01ae74b0 _dispatch_client_callout + 14
	13  libdispatch.dylib                   0x01ad575e _dispatch_main_queue_callback_4CF + 340
	14  CoreFoundation                      0x017a0a5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
	15  CoreFoundation                      0x016e16bb __CFRunLoopRun + 1963
	16  CoreFoundation                      0x016e0ac3 CFRunLoopRunSpecific + 467
	17  CoreFoundation                      0x016e08db CFRunLoopRunInMode + 123
	18  GraphicsServices                    0x036e09e2 GSEventRunModal + 192
	19  GraphicsServices                    0x036e0809 GSEventRun + 104
	20  UIKit                               0x0022cd3b UIApplicationMain + 1225
	21  DataDetectorTest                    0x0000394d main + 141
	22  libdyld.dylib                       0x01d7970d start + 1
)

Steps to Reproduce:
1. Run the attached sample project (on simulator or device)

Expected Results:
No crash

Actual Results:
Crash

Version:
iOS 7.0.3 (11B508)


Notes:


Configuration:
Happens on simulator and device(s)

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!