<?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>165852</bug_id>
          
          <creation_ts>2016-12-14 09:11:02 -0800</creation_ts>
          <short_desc>WebContent crash under WebCore::CachedResource::load in WebCore::FrameLoader::outgoingReferrer const</short_desc>
          <delta_ts>2016-12-14 10:55:08 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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="Antti Koivisto">koivisto</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>beidson</cc>
    
    <cc>cdumez</cc>
    
    <cc>commit-queue</cc>
    
    <cc>dbates</cc>
    
    <cc>japhet</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1259750</commentid>
    <comment_count>0</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2016-12-14 09:11:02 -0800</bug_when>
    <thetext>Null ptr</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259751</commentid>
    <comment_count>1</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2016-12-14 09:11:16 -0800</bug_when>
    <thetext>&lt;rdar://problem/27297153&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259755</commentid>
    <comment_count>2</comment_count>
      <attachid>297093</attachid>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2016-12-14 09:17:57 -0800</bug_when>
    <thetext>Created attachment 297093
patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259761</commentid>
    <comment_count>3</comment_count>
      <attachid>297093</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-12-14 09:24:11 -0800</bug_when>
    <thetext>Comment on attachment 297093
patch

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

&gt; Source/WebCore/loader/FrameLoader.cpp:929
&gt;          // because they need to be contained in iframes with the srcdoc.

Getting a null frame would mean that we have a top-level frame with an srcdoc document. This is weird unless the iframe that has the srcdoc is not yet (or no longer in the tree), i.e. detached.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259770</commentid>
    <comment_count>4</comment_count>
      <attachid>297093</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-12-14 09:27:38 -0800</bug_when>
    <thetext>Comment on attachment 297093
patch

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

&gt;&gt; Source/WebCore/loader/FrameLoader.cpp:929
&gt;&gt;          // because they need to be contained in iframes with the srcdoc.
&gt; 
&gt; Getting a null frame would mean that we have a top-level frame with an srcdoc document. This is weird unless the iframe that has the srcdoc is not yet (or no longer in the tree), i.e. detached.

Based on the trace, I suspect this would be reproducible if we:
1. Created an iframe with an srcdoc but not add it to the document
2. Add an HTMLImageElement to that srcdoc
3. Set the src attribute on that HTMLImageElement

If so, then this comment and assertion are wrong and your fix is indeed right.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259792</commentid>
    <comment_count>5</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2016-12-14 09:53:06 -0800</bug_when>
    <thetext>&gt; If so, then this comment and assertion are wrong and your fix is indeed
&gt; right.

The theory has been that we shouldn&apos;t even try to do any loads in disconnected frames so we shouldn&apos;t get here in the first place. That&apos;s why I didn&apos;t remove the assert.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259793</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-12-14 09:56:22 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; &gt; If so, then this comment and assertion are wrong and your fix is indeed
&gt; &gt; right.
&gt; 
&gt; The theory has been that we shouldn&apos;t even try to do any loads in
&gt; disconnected frames so we shouldn&apos;t get here in the first place. That&apos;s why
&gt; I didn&apos;t remove the assert.

I believe that if you set the src of an HTMLImageElement, the load will go through. It goes through even if the HTMLImageElement is itself detached.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259798</commentid>
    <comment_count>7</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2016-12-14 10:14:31 -0800</bug_when>
    <thetext>I tried this but it doesn&apos;t hit the case:

&lt;iframe srcdoc=&quot;text&quot; onload=&quot;test()&quot;&gt;&lt;/iframe&gt;
&lt;script&gt;
function test() {
    const iframe = document.querySelector(&quot;iframe&quot;);
    const contentDocument = iframe.contentDocument;
    document.body.removeChild(iframe);
    const img = contentDocument.createElement(&quot;img&quot;);
    img.setAttribute(&quot;src&quot;, &quot;foo.png&quot;);
}
&lt;/script&gt;

Note that this doesn&apos;t necessarily have anything to do with srcdoc, local m_frame could be null.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259799</commentid>
    <comment_count>8</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-12-14 10:16:23 -0800</bug_when>
    <thetext>(In reply to comment #7)
&gt; I tried this but it doesn&apos;t hit the case:
&gt; 
&gt; &lt;iframe srcdoc=&quot;text&quot; onload=&quot;test()&quot;&gt;&lt;/iframe&gt;
&gt; &lt;script&gt;
&gt; function test() {
&gt;     const iframe = document.querySelector(&quot;iframe&quot;);
&gt;     const contentDocument = iframe.contentDocument;
&gt;     document.body.removeChild(iframe);
&gt;     const img = contentDocument.createElement(&quot;img&quot;);
&gt;     img.setAttribute(&quot;src&quot;, &quot;foo.png&quot;);
&gt; }
&gt; &lt;/script&gt;
&gt; 
&gt; Note that this doesn&apos;t necessarily have anything to do with srcdoc, local
&gt; m_frame could be null.

FrameLoader::m_frame is a reference so if it is null, we have bigger issues.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259807</commentid>
    <comment_count>9</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2016-12-14 10:27:08 -0800</bug_when>
    <thetext>&gt; FrameLoader::m_frame is a reference so if it is null, we have bigger issues.

True, like dead frame loader.

Anyway, I don&apos;t know how to repro.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259808</commentid>
    <comment_count>10</comment_count>
      <attachid>297093</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-12-14 10:28:07 -0800</bug_when>
    <thetext>Comment on attachment 297093
patch

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

Ok, well we tried. I could not write a test case either.

&gt; Source/WebCore/loader/FrameLoader.cpp:932
&gt; +    if (!frame)

nit: I would have used a ternary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259810</commentid>
    <comment_count>11</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2016-12-14 10:31:26 -0800</bug_when>
    <thetext>&gt; nit: I would have used a ternary.

I like early bailouts for exceptional cases. I feel ternary sort-of signals that both cases are on the same level.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259814</commentid>
    <comment_count>12</comment_count>
      <attachid>297093</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-12-14 10:55:03 -0800</bug_when>
    <thetext>Comment on attachment 297093
patch

Clearing flags on attachment: 297093

Committed r209817: &lt;http://trac.webkit.org/changeset/209817&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1259815</commentid>
    <comment_count>13</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-12-14 10:55:08 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>297093</attachid>
            <date>2016-12-14 09:17:57 -0800</date>
            <delta_ts>2016-12-14 10:55:03 -0800</delta_ts>
            <desc>patch</desc>
            <filename>outgoingReferrer-nullptr.patch</filename>
            <type>text/plain</type>
            <size>1760</size>
            <attacher name="Antti Koivisto">koivisto</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDIwOTgwNSkKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE5IEBACisyMDE2LTEyLTE0ICBBbnR0aSBL
b2l2aXN0byAgPGFudHRpQGFwcGxlLmNvbT4KKworICAgICAgICBXZWJDb250ZW50IGNyYXNoIHVu
ZGVyIFdlYkNvcmU6OkNhY2hlZFJlc291cmNlOjpsb2FkIGluIFdlYkNvcmU6OkZyYW1lTG9hZGVy
OjpvdXRnb2luZ1JlZmVycmVyIGNvbnN0CisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3Jn
L3Nob3dfYnVnLmNnaT9pZD0xNjU4NTIKKyAgICAgICAgPHJkYXI6Ly9wcm9ibGVtLzI3Mjk3MTUz
PgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIFRoZXJl
IGFwcGVhcnMgdG8gYmUgc29tZSBwYXRoIHdoZXJlIHdlIGdldCBoZXJlIHdpdGggYSBudWxsIGZy
YW1lLgorICAgICAgICBObyB0ZX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