Bug 222854 - Nullopt crash in RenderFlexibleBox::computeInnerFlexBaseSizeForChild
Summary: Nullopt crash in RenderFlexibleBox::computeInnerFlexBaseSizeForChild
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
: 222716 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-03-05 20:36 PST by Ryosuke Niwa
Modified: 2021-03-15 18:01 PDT (History)
11 users (show)

See Also:


Attachments
Test (131 bytes, text/html)
2021-03-05 20:36 PST, Ryosuke Niwa
no flags Details
Patch (3.65 KB, patch)
2021-03-06 01:45 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (4.41 KB, patch)
2021-03-10 02:29 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (4.87 KB, patch)
2021-03-10 04:13 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (4.84 KB, patch)
2021-03-10 04:15 PST, Rob Buis
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (4.84 KB, patch)
2021-03-10 04:32 PST, Rob Buis
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (4.29 KB, patch)
2021-03-10 05:02 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (4.50 KB, patch)
2021-03-15 04:32 PDT, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2021-03-05 20:36:17 PST
e.g.

1   0x1a74a4089 WTFCrash
2   0x18cc53389 WTF::Optional<WebCore::LayoutUnit>::value() &&
3   0x18cd8df11 WebCore::RenderFlexibleBox::computeInnerFlexBaseSizeForChild(WebCore::RenderBox&, WebCore::LayoutUnit)
4   0x18cd8e784 WebCore::RenderFlexibleBox::constructFlexItem(WebCore::RenderBox&, bool)
5   0x18cd8989a WebCore::RenderFlexibleBox::layoutFlexItems(bool)
6   0x18cd893a4 WebCore::RenderFlexibleBox::layoutBlock(bool, WebCore::LayoutUnit)
7   0x18ccae529 WebCore::RenderBlock::layout()
8   0x18cc064cc WebCore::RenderElement::layoutIfNeeded()
9   0x18cd8e711 WebCore::RenderFlexibleBox::constructFlexItem(WebCore::RenderBox&, bool)
10  0x18cd8989a WebCore::RenderFlexibleBox::layoutFlexItems(bool)
11  0x18cd893a4 WebCore::RenderFlexibleBox::layoutBlock(bool, WebCore::LayoutUnit)
12  0x18ccae529 WebCore::RenderBlock::layout()
13  0x18ccc94c2 WebCore::RenderBlockFlow::layoutBlockChild(WebCore::RenderBox&, WebCore::RenderBlockFlow::MarginInfo&, WebCore::LayoutUnit&, WebCore::LayoutUnit&)
14  0x18ccc7e04 WebCore::RenderBlockFlow::layoutBlockChildren(bool, WebCore::LayoutUnit&)
15  0x18ccc6c83 WebCore::RenderBlockFlow::layoutBlock(bool, WebCore::LayoutUnit)
16  0x18ccae529 WebCore::RenderBlock::layout()
17  0x18cf472f3 WebCore::RenderView::layout()
18  0x18c4393c1 WebCore::FrameViewLayoutContext::layout()
19  0x18b6834b6 WebCore::Document::implicitClose()
20  0x18c232a7b WebCore::FrameLoader::checkCallImplicitClose()
21  0x18c2324aa WebCore::FrameLoader::checkCompleted()
22  0x18c230597 WebCore::FrameLoader::finishedParsing()
23  0x18b698026 WebCore::Document::finishedParsing()
24  0x18bdc2228 WebCore::HTMLConstructionSite::finishedParsing()
25  0x18be07f67 WebCore::HTMLTreeBuilder::finished()
26  0x18bdc9858 WebCore::HTMLDocumentParser::end()
27  0x18bdc7528 WebCore::HTMLDocumentParser::attemptToRunDeferredScriptsAndEnd()
28  0x18bdc7267 WebCore::HTMLDocumentParser::prepareToStopParsing()
29  0x18bdc98c2 WebCore::HTMLDocumentParser::attemptToEnd()
30  0x18bdc9989 WebCore::HTMLDocumentParser::finish()
31  0x18c20aaa4 WebCore::DocumentWriter::end()

<rdar://problem/72991927>
Comment 1 Ryosuke Niwa 2021-03-05 20:36:49 PST
Created attachment 422471 [details]
Test
Comment 2 Ryosuke Niwa 2021-03-05 20:37:35 PST
Reproduced with DumpRenderTree and WebKitTestRunner at r274025.
Comment 3 Rob Buis 2021-03-06 01:45:03 PST
Created attachment 422477 [details]
Patch
Comment 4 Sergio Villar Senin 2021-03-07 23:51:13 PST
Comment on attachment 422477 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422477&action=review

> Source/WebCore/rendering/RenderFlexibleBox.cpp:933
> +        return std::max(0_lu, computeMainAxisExtentForChild(child, MainOrPreferredSize, flexBasis).valueOr(0_lu));

We're using value() unconditionally because this is the childMainSizeIsDefinite() branch. Why are we getting a nullopt here?
Comment 5 Rob Buis 2021-03-08 00:10:33 PST
Comment on attachment 422477 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422477&action=review

>> Source/WebCore/rendering/RenderFlexibleBox.cpp:933
>> +        return std::max(0_lu, computeMainAxisExtentForChild(child, MainOrPreferredSize, flexBasis).valueOr(0_lu));
> 
> We're using value() unconditionally because this is the childMainSizeIsDefinite() branch. Why are we getting a nullopt here?

Because we are having a !mainAxisIsChildInlineAxis case, we can return a null opt in computeMainAxisExtentForChild:
        if (!height)
            return height;
Comment 6 Carlos Garcia Campos 2021-03-08 02:23:13 PST
*** Bug 222716 has been marked as a duplicate of this bug. ***
Comment 7 Rob Buis 2021-03-10 02:29:39 PST
Created attachment 422810 [details]
Patch
Comment 8 Sergio Villar Senin 2021-03-10 02:33:54 PST
Comment on attachment 422810 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422810&action=review

> Source/WebCore/rendering/RenderBox.cpp:3044
> +    if (height.isIntrinsic() || height.isMinIntrinsic())

In this case you can use height.isLegacyIntrinsic()
Comment 9 Rob Buis 2021-03-10 04:13:30 PST
Created attachment 422815 [details]
Patch
Comment 10 Rob Buis 2021-03-10 04:15:52 PST
Created attachment 422816 [details]
Patch
Comment 11 Rob Buis 2021-03-10 04:32:51 PST
Created attachment 422818 [details]
Patch
Comment 12 Rob Buis 2021-03-10 04:59:45 PST
Comment on attachment 422810 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422810&action=review

>> Source/WebCore/rendering/RenderBox.cpp:3044
>> +    if (height.isIntrinsic() || height.isMinIntrinsic())
> 
> In this case you can use height.isLegacyIntrinsic()

Alas, private :)
Comment 13 Rob Buis 2021-03-10 05:02:47 PST
Created attachment 422819 [details]
Patch
Comment 14 Sergio Villar Senin 2021-03-15 03:48:06 PDT
Comment on attachment 422819 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422819&action=review

> Source/WebCore/rendering/RenderBox.cpp:3025
> +    if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent() || logicalHeightLength.isFitContent() || logicalHeightLength.isMinIntrinsic()) {

Now that you change this maybe we could modify a bit the if block because it's really confusing. I'm talking about doing something like

if (intrinsicContentHeight && style().boxSizing() == BoxSizing::BorderBox)
  return intrinsicContentHeight.value() + borderAndPaddingLogicalHeight();
return intrinsicContentHeight;

> LayoutTests/fast/flexbox/indefinite-width-crash.html:2
> +<html><head>

Nit: both not needed as you're already using DOCTYPE

> LayoutTests/fast/flexbox/indefinite-width-crash.html:10
> +  };

Can we just use 0 as delay instead of 50?
Comment 15 Rob Buis 2021-03-15 04:32:54 PDT
Created attachment 423156 [details]
Patch
Comment 16 Rob Buis 2021-03-15 05:17:33 PDT
Comment on attachment 422819 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422819&action=review

>> Source/WebCore/rendering/RenderBox.cpp:3025
>> +    if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent() || logicalHeightLength.isFitContent() || logicalHeightLength.isMinIntrinsic()) {
> 
> Now that you change this maybe we could modify a bit the if block because it's really confusing. I'm talking about doing something like
> 
> if (intrinsicContentHeight && style().boxSizing() == BoxSizing::BorderBox)
>   return intrinsicContentHeight.value() + borderAndPaddingLogicalHeight();
> return intrinsicContentHeight;

Done.

>> LayoutTests/fast/flexbox/indefinite-width-crash.html:2
>> +<html><head>
> 
> Nit: both not needed as you're already using DOCTYPE

Removed.

>> LayoutTests/fast/flexbox/indefinite-width-crash.html:10
>> +  };
> 
> Can we just use 0 as delay instead of 50?

Yes, that works too, fixed.
Comment 17 EWS 2021-03-15 06:18:29 PDT
Committed r274419: <https://commits.webkit.org/r274419>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 423156 [details].