WebCore crash on accessing UITextView's typingAttributes property

Originator:lee.hericks
Number:rdar://13222522 Date Originated:15-Feb-2013 04:12 PM
Status:Open Resolved:
Product:iPhone SDK Product Version:6.1
Classification:Crash Reproducible:YES
 
15-Feb-2013 04:12 PM Lee Hericks:
Summary:

It appears that processing of an NSAttributedString in UITextView is not thread-safe.  When accessing the typingAttributes property WebCore crashes.

Steps to Reproduce:

1. Programmatically create a UITextView.
2. Set an attributed string to the attributedText iVar
3. Try to get the typingAttributes

Expected Results:

A NSDictionary of attributes should be returned.

Actual Results:

WebCore::Frame::styleAtSelectionStart() const crashes with EXC_BAD_ACCESS

Regression:

Notes:

UITextView objects from nib files will not crash if the nib sets the text property.  In some cases, setting the text property before setting an attributed string can also avoid the crash.  So it seems that:

Programmer sets attributed string
NSHTMLWriter transforms the attributed string to html
The text property gets set to a plain text version of the attributed string

..but requesting the typingAttributes before this processing can complete doesn't do a safety check for the text being nil, and WebCore is C++ and doesn't have the joy of sending messages to nil.

Work around:

Delay access to the typing attributes for a small time, see example project.

15-Feb-2013 04:12 PM Lee Hericks:
'TypingAttributesBug.zip' and 'TypingAttributesBug  2-15-13 4-11 PM.crash' were successfully uploaded

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!