Crash when attempting to undo after unsuccessfully pasting into UITextField
| Originator: | web | ||
| Number: | rdar://32508213 | Date Originated: | |
| Status: | Closed | Resolved: | |
| Product: | iOS + UIKit | Product Version: | 10.3.x |
| Classification: | Crash | Reproducible: | Always |
Summary:
When attempting to undo a paste operation on a UITextField that implements the '- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string' delegate method which returned 'NO' the app will crash:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSBigMutableString substringWithRange:]: Range {0, 568} out of bounds; string length 0'
Steps to Reproduce:
1. Implement an app with a UITextField
2. Implement the UITextFieldDelegate protocol and assign the UITextField delegate
3. Implement the '- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string' method
4. Return NO from that method
5. Run app and attempt to paste text into the UITextField and observe that no text is actually pasted
6. Shake the phone to trigger the Undo prompt
7. Tap the Undo button in the prompt and observe crash
Expected Results:
The app should not crash.
Actual Results:
The app crashes due to iOS recording the unsuccessful paste operation as something that can be undone.
Regression:
Always occours
Notes:
Full crash report:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSBigMutableString substringWithRange:]: Range {0, 568} out of bounds; string length 0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010abfbb0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010a33e141 objc_exception_throw + 48
2 CoreFoundation 0x000000010ac64625 +[NSException raise:format:] + 197
3 Foundation 0x0000000109e19a61 -[NSString substringWithRange:] + 131
4 UIKit 0x000000010c85baf8 -[NSTextStorage(UIKitUndoExtensions) _undoRedoAttributedSubstringFromRange:] + 136
5 UIKit 0x000000010c85bf4a -[_UITextUndoOperationReplace undoRedo] + 306
6 Foundation 0x0000000109ed0463 -[_NSUndoStack popAndInvoke] + 280
7 Foundation 0x0000000109ed01f2 -[NSUndoManager undoNestedGroup] + 433
8 UIKit 0x000000010bc7a138 -[UIApplication alertView:clickedButtonAtIndex:] + 151
9 UIKit 0x000000010bfe98fc -[UIAlertView _prepareToDismissForTappedIndex:] + 134
10 UIKit 0x000000010bfe933e __35-[UIAlertView _prepareAlertActions]_block_invoke.50 + 53
11 UIKit 0x000000010bfd2404 -[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:] + 1080
12 UIKit 0x000000010c75ceca -[_UIAlertControllerView interfaceAction:invokeActionHandler:completion:] + 337
13 UIKit 0x000000010c82f398 -[UIInterfaceActionGroupView interfaceAction:invokeActionHandler:completion:] + 105
14 UIKit 0x000000010c54aa23 -[UIInterfaceAction _invokeHandlerWithCompletionBlock:] + 163
15 UIKit 0x000000010c316d4f -[UIInterfaceActionSelectionTrackingController _handleActionSelectionGestureRecognizer:] + 784
16 UIKit 0x000000010c19dc09 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
17 UIKit 0x000000010c1a5a07 _UIGestureRecognizerSendTargetActions + 109
18 UIKit 0x000000010c1a33bb _UIGestureRecognizerSendActions + 225
19 UIKit 0x000000010c1a267e -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 981
20 UIKit 0x000000010c18ee02 _UIGestureEnvironmentUpdate + 1219
21 UIKit 0x000000010c18e8f3 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
22 UIKit 0x000000010c18daba -[UIGestureEnvironment _updateGesturesForEvent:window:] + 274
23 UIKit 0x000000010bcd9b9a -[UIWindow sendEvent:] + 4092
24 UIKit 0x000000010bc867b0 -[UIApplication sendEvent:] + 352
25 UIKit 0x000000010c469adc __dispatchPreprocessedEventFromEventQueue + 2926
26 UIKit 0x000000010c461a3a __handleEventQueue + 1122
27 CoreFoundation 0x000000010aba1c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
28 CoreFoundation 0x000000010ab870cf __CFRunLoopDoSources0 + 527
29 CoreFoundation 0x000000010ab865ff __CFRunLoopRun + 911
30 CoreFoundation 0x000000010ab86016 CFRunLoopRunSpecific + 406
31 GraphicsServices 0x000000010fd84a24 GSEventRunModal + 62
32 UIKit 0x000000010bc690d4 UIApplicationMain + 159
33 MyApp 0x00000001087453c7 main + 55
34 libdyld.dylib 0x000000010df3665d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Apple have responding marking the Radar a duplicate of : 16697134
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!
Apple reply
Engineering has determined that your bug report (32508213) is a duplicate of 16697134 and will be closed.
The open or closed status of the original report your bug was duplicated to appears in a gray text box within the bug detail section of the bug reporter user interface. For security and privacy reasons, we don't provide access to the original bug yours was duped to.