Arabic text crashes in UITextView when line wrapped.

Originator:padraig.kennedy
Number:rdar://15544314 Date Originated:24 November 2013
Status:Closed Resolved:03-Jun-2014
Product:iOS SDK Product Version:7.1
Classification:Crash Reproducible:Always
 
Summary:
Creating an attributed string with a long string of arabic text and setting a paragraph style on it will crash when assigned to  UITextView's attributedString

Steps to Reproduce:
1. Create a string: @"حلقتنا مدحوشة ننتندو اليوم، نسير معهم على Wind Waker HD و The Wonderful 101 ورأي عام على الجهاز بعد شوية وقت معه، عصام ياخذنا للمحكمة مع Ace Attorney: Duale Destinies للعدس ويزيد والداوود مع رحلة في صميم الطفولة ويّا Pokemon X & Y.";

2. Give it a paragraph style with NSTextAlignmentJustified (there are other combinations of styles that cause the crash, this is just the easiest to reproduce. I suspect the issue occurs when the text view breaks the line on a particular glyph)

3. Set it to a UITextView that is on the screen.

Expected Results:
The text should be rendered.

Actual Results:
The app crashes with this backtrace:

* thread #1: tid = 0x489055, 0x058b68c4 UIFoundation`_NSGlyphTreeGetCGGlyphsInRange + 1303, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x8)
    frame #0: 0x058b68c4 UIFoundation`_NSGlyphTreeGetCGGlyphsInRange + 1303
    frame #1: 0x058fa7b7 UIFoundation`-[NSLayoutManager getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:] + 82
    frame #2: 0x0593348b UIFoundation`-[NSTypesetter getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:] + 118
    frame #3: 0x058ddb6e UIFoundation`-[NSATSLineFragment saveWithGlyphOrigin:] + 5232
    frame #4: 0x058d1d2b UIFoundation`-[NSATSTypesetter _layoutLineFragmentStartingWithGlyphAtIndex:characterIndex:atPoint:renderingContext:] + 5992
    frame #5: 0x058d26d6 UIFoundation`-[NSATSTypesetter layoutParagraphAtPoint:] + 163
    frame #6: 0x059318c5 UIFoundation`-[NSTypesetter _layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:maxCharacterIndex:nextGlyphIndex:nextCharacterIndex:] + 4461
    frame #7: 0x05932e6f UIFoundation`-[NSTypesetter layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments:] + 259
    frame #8: 0x058d3161 UIFoundation`-[NSATSTypesetter layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments:] + 513
    frame #9: 0x058bd40e UIFoundation`-[NSLayoutManager(NSPrivate) _fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] + 1266
    frame #10: 0x058c475e UIFoundation`_NSFastFillAllLayoutHolesForGlyphRange + 1632
    frame #11: 0x058f9bc2 UIFoundation`-[NSLayoutManager ensureLayoutForGlyphRange:] + 31
    frame #12: 0x011ffe13 UIKit`-[_UITextContainerView _ensureLayoutCompleteForRect:withExtensionFactor:minimumExtensionDistance:repetitions:] + 527
    frame #13: 0x011ffeaa UIKit`-[_UITextContainerView _ensureLayoutCompleteForRect:withExtension:] + 96
    frame #14: 0x011ff743 UIKit`__33-[_UITextContainerView drawRect:]_block_invoke + 118
    frame #15: 0x05921f18 UIFoundation`-[NSTextStorage coordinateReading:] + 51
    frame #16: 0x011ff69b UIKit`-[_UITextContainerView drawRect:] + 314
    frame #17: 0x00b79e56 UIKit`-[UIView(CALayerDelegate) drawLayer:inContext:] + 504
    frame #18: 0x008d0d19 QuartzCore`-[CALayer drawInContext:] + 123
    frame #19: 0x058f1d18 UIFoundation`-[_UITextTiledLayer drawDirtyLayer:intoContext:] + 171
    frame #20: 0x058f1bbb UIFoundation`-[_UITileLayer drawInContext:] + 64
    frame #21: 0x008d0c4a QuartzCore`backing_callback(CGContext*, void*) + 96
    frame #22: 0x007c092c QuartzCore`CABackingStoreUpdate_ + 2656
    frame #23: 0x008d0be2 QuartzCore`___ZN2CA5Layer8display_Ev_block_invoke + 93
    frame #24: 0x00904fbf QuartzCore`x_blame_allocations + 15
    frame #25: 0x008d0a4d QuartzCore`CA::Layer::display_() + 1519
    frame #26: 0x008d0c99 QuartzCore`-[CALayer _display] + 33
    frame #27: 0x008d0456 QuartzCore`CA::Layer::display() + 144
    frame #28: 0x008d0c73 QuartzCore`-[CALayer display] + 33
    frame 

Version:
iOS 7.1, Xcode 5.1

Notes:


Configuration:
Happens on simulator and on devices.

Attachments:
'TextViewCrash.zip' was successfully uploaded.

Comments

We believe this issue has been addressed. Please verify with iOS 8 beta (Build 12A4265u) release, and reply back with your results.

iOS 8 beta (Build 12A4265u) https://developer.apple.com/devcenter/ios/index.action Posted Date: June 2, 2014

If this issue is still occurring, please include any relevant logs, and or a test case with your update.

Logging Instructions/Test Case Requirements: https://developer.apple.com/bug-reporting/ios/

By padraig.kennedy at July 31, 2014, 4:23 p.m. (reply...)

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!