Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid querying for NSAttributedString attributes on empty string #1614

Merged
merged 1 commit into from
Aug 13, 2019

Conversation

rahul-malik
Copy link
Contributor

@rahul-malik rahul-malik commented Aug 13, 2019

Resolves crash with stack trace:

Fatal Exception: NSRangeException
NSRLEArray objectAtIndex:effectiveRange:: Out of bounds

0  CoreFoundation                 0x1eab6298c __exceptionPreprocess
1  libobjc.A.dylib                0x1e9d3b9f8 objc_exception_throw
2  CoreFoundation                 0x1eaa6cbc0 -[NSCache init]
3  Foundation                     0x1eb4e4a7c -[NSRLEArray objectAtIndex:effectiveRange:]
4  Foundation                     0x1eb4e4c34 -[NSConcreteAttributedString attribute:atIndex:effectiveRange:]
5  PinterestEnterprise            0x10419ecdc -[ASTextKitContext initWithAttributedString:tintColor:lineBreakMode:maximumNumberOfLines:exclusionPaths:constrainedSize:] + 68 (ASTextKitContext.mm:68)
6  PinterestEnterprise            0x1041a3c48 -[ASTextKitRenderer initWithTextKitAttributes:constrainedSize:] + 63 (ASTextKitRenderer.mm:63)
7  PinterestEnterprise            0x104107d08 rendererForAttributes(ASTextKitAttributes, CGSize) + 126 (ASTextNode.mm:126)
8  PinterestEnterprise            0x104108bb8 -[ASTextNode _locked_rendererWithBounds:] + 367 (ASTextNode.mm:367)
9  PinterestEnterprise            0x104108fa8 -[ASTextNode calculateSizeThatFits:] + 426 (ASTextNode.mm:426)
10 PinterestEnterprise            0x1040d4828 -[ASDisplayNode(ASLayoutSpec) calculateLayoutLayoutSpec:] + 43 (ASDisplayNode+LayoutSpec.mm:43)
11 PinterestEnterprise            0x1040d7f58 -[ASDisplayNode calculateLayoutThatFits:] + 1056 (ASDisplayNode.mm:1056)
12 PinterestEnterprise            0x1040d7ebc -[ASDisplayNode calculateLayoutThatFits:restrictedToSize:relativeToParentSize:] + 1048 (ASDisplayNode.mm:1048)
13 PinterestEnterprise            0x1040d07cc -[ASDisplayNode(ASLayoutElement) layoutThatFits:parentSize:] + 109 (ASDisplayNode+Layout.mm:109)
14 PinterestEnterprise            0x10416dd68 crossChildLayout(ASStackLayoutSpecChild const&, ASStackLayoutSpecStyle const&, double, double, double, double, CGSize) + 65 (ASStackUnpositionedLayout.mm:65)
15 PinterestEnterprise            0x10416da98 invocation function for block in layoutItemsAlongUnconstrainedStackDimension(std::__1::vector<ASStackLayoutSpecItem, std::__1::allocator<ASStackLayoutSpecItem> >&, ASStackLayoutSpecStyle const&, bool, ASSizeRange const&, CGSize, bool) + 689 (ASStackUnpositionedLayout.mm:689)
16 PinterestEnterprise            0x10416d900 dispatchApplyIfNeeded(unsigned long, bool, void (unsigned long) block_pointer) + 83 (ASStackUnpositionedLayout.mm:83)
17 PinterestEnterprise            0x10416cbd8 ASStackUnpositionedLayout::compute(std::__1::vector<ASStackLayoutSpecChild, std::__1::allocator<ASStackLayoutSpecChild> > const&, ASStackLayoutSpecStyle const&, ASSizeRange const&, bool) + 636 (ASStackUnpositionedLayout.mm:636)
18 PinterestEnterprise            0x104154e8c -[ASStackLayoutSpec calculateLayoutThatFits:] + 149 (ASStackLayoutSpec.mm:149)
19 PinterestEnterprise            0x104151c68 -[ASLayoutSpec calculateLayoutThatFits:restrictedToSize:relativeToParentSize:] + 80 (ASLayoutSpec.mm:80)
20 PinterestEnterprise            0x104151af8 -[ASLayoutSpec layoutThatFits:parentSize:] + 80 (ASLayoutSpec.mm:80)
21 PinterestEnterprise            0x10414b9e8 -[ASInsetLayoutSpec calculateLayoutThatFits:restrictedToSize:relativeToParentSize:] + 102 (ASInsetLayoutSpec.mm:102)
22 PinterestEnterprise            0x104151af8 -[ASLayoutSpec layoutThatFits:parentSize:] + 80 (ASLayoutSpec.mm:80)
23 PinterestEnterprise            0x1040d49a8 -[ASDisplayNode(ASLayoutSpec) calculateLayoutLayoutSpec:] + 93 (ASDisplayNode+LayoutSpec.mm:93)
24 PinterestEnterprise            0x1040d7f58 -[ASDisplayNode calculateLayoutThatFits:] + 1056 (ASDisplayNode.mm:1056)
25 PinterestEnterprise            0x1040d7ebc -[ASDisplayNode calculateLayoutThatFits:restrictedToSize:relativeToParentSize:] + 1048 (ASDisplayNode.mm:1048)

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for adding new tests!

@rahul-malik rahul-malik merged commit 4caf951 into master Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants