<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>186393</bug_id>
          
          <creation_ts>2018-06-07 06:47:46 -0700</creation_ts>
          <short_desc>Crash under Page::scrollingCoordinator()</short_desc>
          <delta_ts>2018-06-07 08:29:43 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>Safari 11</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>macOS 10.13</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Antoine Quint">graouts</reporter>
          <assigned_to name="Antoine Quint">graouts</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>dino</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1430805</commentid>
    <comment_count>0</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2018-06-07 06:47:46 -0700</bug_when>
    <thetext>We&apos;ve been getting reports of crashes in Page::scrollingCoordinator() with the following trace:

0   com.apple.WebCore             	0x00007fff55293549 WebCore::Page::scrollingCoordinator() + 9
1   com.apple.WebCore             	0x00007fff552d6028 WebCore::RenderLayer::~RenderLayer() + 408
2   com.apple.WebCore             	0x00007fff552d5e7e WebCore::RenderLayer::~RenderLayer() + 14
3   com.apple.WebCore             	0x00007fff552d5a01 WebCore::RenderLayerModelObject::willBeDestroyed() + 145
4   com.apple.WebCore             	0x00007fff552d5964 WebCore::RenderBoxModelObject::willBeDestroyed() + 452
5   com.apple.WebCore             	0x00007fff552d578c WebCore::RenderBox::willBeDestroyed() + 476
6   com.apple.WebCore             	0x00007fff552d5522 WebCore::RenderObject::destroy() + 82
7   com.apple.WebCore             	0x00007fff564aa838 WebCore::RenderElement::removeAndDestroyChild(WebCore::RenderObject&amp;) + 56
8   com.apple.WebCore             	0x00007fff565f07f1 WebCore::RenderTreeUpdater::tearDownRenderers(WebCore::Element&amp;, WebCore::RenderTreeUpdater::TeardownType)::$_8::operator()(unsigned int) const + 161
9   com.apple.WebCore             	0x00007fff565eff5c WebCore::RenderTreeUpdater::tearDownRenderers(WebCore::Element&amp;, WebCore::RenderTreeUpdater::TeardownType) + 1100
10  com.apple.WebCore             	0x00007fff55ef32d2 WebCore::Document::destroyRenderTree() + 210
11  com.apple.WebCore             	0x00007fff552d4dce WebCore::Document::prepareForDestruction() + 654
12  com.apple.WebCore             	0x00007fff56238841 WebCore::Frame::setView(WTF::RefPtr&lt;WebCore::FrameView, WTF::DumbPtrTraits&lt;WebCore::FrameView&gt; &gt;&amp;&amp;) + 177
13  com.apple.WebCore             	0x00007fff553224c9 WebCore::FrameLoader::detachFromParent() + 537
14  com.apple.WebCore             	0x00007fff55361a36 WebCore::FrameLoader::frameDetached() + 70
15  com.apple.WebCore             	0x00007fff55361994 WebCore::HTMLFrameOwnerElement::disconnectContentFrame() + 36
16  com.apple.WebCore             	0x00007fff55ede94b WebCore::disconnectSubframes(WebCore::ContainerNode&amp;, WebCore::SubframeDisconnectPolicy) + 299
17  com.apple.WebCore             	0x00007fff552d4d84 WebCore::Document::prepareForDestruction() + 580
18  com.apple.WebCore             	0x00007fff553ce48d WebCore::CachedFrame::destroy() + 253
19  com.apple.WebCore             	0x00007fff56010b74 WebCore::PageCache::prune(WebCore::PruningReason) + 100
20  com.apple.WebCore             	0x00007fff56010af8 WebCore::PageCache::pruneToSizeNow(unsigned int, WebCore::PruningReason) + 24
21  com.apple.WebKit              	0x00007fff56bd5fc5 IPC::Connection::dispatchMessage(std::__1::unique_ptr&lt;IPC::Decoder, std::__1::default_delete&lt;IPC::Decoder&gt; &gt;) + 119
22  com.apple.WebKit              	0x00007fff56bd8b1c IPC::Connection::dispatchOneMessage() + 176
23  com.apple.JavaScriptCore      	0x00007fff4bbddf6c WTF::RunLoop::performWork() + 236
24  com.apple.JavaScriptCore      	0x00007fff4bbde202 WTF::RunLoop::performWork(void*) + 34
25  com.apple.CoreFoundation      	0x00007fff47fc6a61 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26  com.apple.CoreFoundation      	0x00007fff4808047c __CFRunLoopDoSource0 + 108
27  com.apple.CoreFoundation      	0x00007fff47fa94c0 __CFRunLoopDoSources0 + 208
28  com.apple.CoreFoundation      	0x00007fff47fa893d __CFRunLoopRun + 1293
29  com.apple.CoreFoundation      	0x00007fff47fa81a3 CFRunLoopRunSpecific + 483
30  com.apple.HIToolbox           	0x00007fff47290d96 RunCurrentEventLoopInMode + 286
31  com.apple.HIToolbox           	0x00007fff47290b06 ReceiveNextEventCommon + 613
32  com.apple.HIToolbox           	0x00007fff47290884 _BlockUntilNextEventMatchingListInModeWithFilter + 64
33  com.apple.AppKit              	0x00007fff45543b53 _DPSNextEvent + 2085
34  com.apple.AppKit              	0x00007fff45cd9eb0 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
35  com.apple.AppKit              	0x00007fff45538965 -[NSApplication run] + 764
36  com.apple.AppKit              	0x00007fff45507b3e NSApplicationMain + 804
37  libxpc.dylib                  	0x00007fff70618f57 _xpc_objc_main + 580
38  libxpc.dylib                  	0x00007fff70617baa xpc_main + 417
39  com.apple.WebKit.WebContent   	0x1048c46a1 main + 490 (/BuildRoot/Library/Caches/com.apple.xbs/Sources/WebKit2/WebKit2-7605.1.33.1.2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:148)
40  libdyld.dylib                 	0x00007fff702be015 start + 1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1430806</commentid>
    <comment_count>1</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2018-06-07 06:48:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/38424306&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1430807</commentid>
    <comment_count>2</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2018-06-07 06:49:20 -0700</bug_when>
    <thetext>ScrollingCoordinator* Page::scrollingCoordinator()
{
    if (!m_scrollingCoordinator &amp;&amp; m_settings-&gt;scrollingCoordinatorEnabled()) {
        m_scrollingCoordinator = chrome().client().createScrollingCoordinator(*this);
        if (!m_scrollingCoordinator)
            m_scrollingCoordinator = ScrollingCoordinator::create(this);
    }

    return m_scrollingCoordinator.get();
}

I suppose we could crash if either m_settings is nullptr or if m_scrollingCoordinator is nullptr and m_settings-&gt;scrollingCoordinatorEnabled() is false.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1430808</commentid>
    <comment_count>3</comment_count>
      <attachid>342156</attachid>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2018-06-07 06:51:33 -0700</bug_when>
    <thetext>Created attachment 342156
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1430811</commentid>
    <comment_count>4</comment_count>
      <attachid>342156</attachid>
    <who name="alan">zalan</who>
    <bug_when>2018-06-07 07:19:58 -0700</bug_when>
    <thetext>Comment on attachment 342156
Patch

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

&gt; Source/WebCore/page/Page.cpp:377
&gt; +    if (!m_settings || !m_settings-&gt;scrollingCoordinatorEnabled())
&gt; +        return nullptr;

m_settings can&apos;t really be nullptr and as long as the Page::settings() returns Settings&amp; we should not add random nullptr checks (since the contract is that as long as the page is valid, the settings is valid too )
Not sure way we would crash with m_scrollingCoordinator nullptr. If we end up not constructing a scrollingCoordinator object, m_scrollingCoordinator.get() would just return nullptr.
Also I think this stacktrace is about accessing an invalid Page object.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1430831</commentid>
    <comment_count>5</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2018-06-07 08:22:29 -0700</bug_when>
    <thetext>But the call site in ~RenderLayer() accesses the Page through renderer().page().scrollingCoordinator() and this should return a Page&amp;, so this ought not be null either.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1430836</commentid>
    <comment_count>6</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2018-06-07 08:25:57 -0700</bug_when>
    <thetext>(In reply to Antoine Quint from comment #5)
&gt; But the call site in ~RenderLayer() accesses the Page through
&gt; renderer().page().scrollingCoordinator() and this should return a Page&amp;, so
&gt; this ought not be null either.
Sure and if it turns out to be null, then we need to find out why and assess whether it&apos;s a valid case and either change the contract (Page&amp; -&gt; Page*) or fix the broken case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1430837</commentid>
    <comment_count>7</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2018-06-07 08:29:43 -0700</bug_when>
    <thetext>(In reply to zalan from comment #6)
&gt; (In reply to Antoine Quint from comment #5)
&gt; &gt; But the call site in ~RenderLayer() accesses the Page through
&gt; &gt; renderer().page().scrollingCoordinator() and this should return a Page&amp;, so
&gt; &gt; this ought not be null either.
&gt; Sure and if it turns out to be null, then we need to find out why and assess
&gt; whether it&apos;s a valid case and either change the contract (Page&amp; -&gt; Page*) or
&gt; fix the broken case.
My point is that the combination of null checks and returning the reference is confusing and should be avoided. it&apos;s either guaranteed to be not null -&gt; &amp;, or null -&gt; * (there are obviously some exceptions but I don&apos;t think this falls into that category)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>342156</attachid>
            <date>2018-06-07 06:51:33 -0700</date>
            <delta_ts>2018-06-07 07:19:58 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-186393-20180607155132.patch</filename>
            <type>text/plain</type>
            <size>1789</size>
            <attacher name="Antoine Quint">graouts</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjMyNTczCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggYzI3ZTZiNDVkNjdkN2U0
NDBmNTMxMTg0ZjVmNjJmYWI3NDkyZDE3ZC4uMWIyYWQwMTVmMmQyZmNlODg1MDUwNjU0ZWMwMzIz
YmYxMDlmODVjZiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE4IEBACisyMDE4LTA2LTA3ICBBbnRv
aW5lIFF1aW50ICA8Z3Jhb3V0c0BhcHBsZS5jb20+CisKKyAgICAgICAgQ3Jhc2ggdW5kZXIgUGFn
ZTo6c2Nyb2xsaW5nQ29vcmRpbmF0b3IoKQorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9y
Zy9zaG93X2J1Zy5jZ2k/aWQ9MTg2MzkzCisgICAgICAgIDxyZGFyOi8vcHJvYmxlbS8zODQyNDMw
Nj4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBCbGlu
ZCBhdHRlbXB0IGF0IGZpeGluZyBhIGNyYXNoIGluIFBhZ2U6OnNjcm9sbGluZ0Nvb3JkaW5hdG9y
KCkuIExvb2tpbmcgYXQgdGhlIGNvZGUsIHdlIGNvdWxkIGNyYXNoIGlmIGVpdGhlcgorICAgICAg
ICBtX3NldHRpbmdzIGlzIG51bGxwdHIgb3IgaWYgbV9zY3JvbGxpbmdDb29yZGluYXRvciBpcyBu
dWxsc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ICAgaWYgKCFtX3NldHRpbmdzIHx8
ICFtX3NldHRpbmdzLT5zY3JvbGxpbmdDb29yZGluYXRvckVuYWJsZWQoKSkKKyAgICAgICAgcmV0
dXJuIG51bGxwdHI7CisKKyAgICBpZiAoIW1fc2Nyb2xsaW5nQ29vcmRpbmF0b3IpIHsKICAgICAg
ICAgbV9zY3JvbGxpbmdDb29yZGluYXRvciA9IGNocm9tZSgpLmNsaWVudCgpLmNyZWF0ZVNjcm9s
bGluZ0Nvb3JkaW5hdG9yKCp0aGlzKTsKICAgICAgICAgaWYgKCFtX3Njcm9sbGluZ0Nvb3JkaW5h
dG9yKQogICAgICAgICAgICAgbV9zY3JvbGxpbmdDb29yZGluYXRvciA9IFNjcm9sbGluZ0Nvb3Jk
aW5hdG9yOjpjcmVhdGUodGhpcyk7Cg==
</data>
<flag name="review"
          id="360288"
          type_id="1"
          status="-"
          setter="zalan"
    />
          </attachment>
      

    </bug>

</bugzilla>