<?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>77817</bug_id>
          
          <creation_ts>2012-02-04 16:26:10 -0800</creation_ts>
          <short_desc>CachedResourceLoader is destroyed before CSSFontSelector is destroyed</short_desc>
          <delta_ts>2012-02-22 10:05:58 -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>528+ (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="Ryosuke Niwa">rniwa</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>bashi</cc>
    
    <cc>beidson</cc>
    
    <cc>darin</cc>
    
    <cc>eric</cc>
    
    <cc>hyatt</cc>
    
    <cc>japhet</cc>
    
    <cc>kling</cc>
    
    <cc>koivisto</cc>
    
    <cc>mitz</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>549491</commentid>
    <comment_count>0</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-04 16:26:10 -0800</bug_when>
    <thetext>In Document::~Document, we&apos;re explicitly calling m_cachedResourceLoader.clear(). However, CSSFontSelector, which is owned by CSSStyleSelector, calls CachedResourceLoader::decrementRequestCount at the end of the destructor, accessing the freed-memory.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>549493</commentid>
    <comment_count>1</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-04 16:28:27 -0800</bug_when>
    <thetext>The following stack trace can be obtained on PerformanceTests/Parser/html5-full-renderer.html on debug builds of Mac port by setting a break point inside CachedResourceLoader::decrementRequestCount after hitting an assertion in CachedResourceLoader::~CachedResourceLoader.

#0	0x1014e69aa in WebCore::CachedResourceLoader::decrementRequestCount at CachedResourceLoader.cpp:714
#1	0x1015d09b6 in WebCore::CSSFontSelector::clearDocument at CSSFontSelector.cpp:586
#2	0x1016bf3f0 in WebCore::CSSStyleSelector::~CSSStyleSelector at CSSStyleSelector.cpp:572
#3	0x1017a4cc7 in WTF::deleteOwnedPtr&lt;WebCore::CSSStyleSelector&gt; at OwnPtrCommon.h:54
#4	0x1017a4e26 in WTF::OwnPtr&lt;WebCore::CSSStyleSelector&gt;::~OwnPtr at OwnPtr.h:55
#5	0x10178292d in WebCore::Document::~Document at Document.cpp:580
#6	0x101bfc883 in WebCore::HTMLDocument::~HTMLDocument at HTMLDocument.cpp:91
#7	0x1017906c6 in WebCore::Document::guardDeref at Document.h:253
#8	0x10177ac28 in WebCore::Document::removedLastRef at Document.cpp:626
#9	0x1015b94dd in WebCore::TreeShared&lt;WebCore::ContainerNode&gt;::deref at TreeShared.h:79</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>549507</commentid>
    <comment_count>2</comment_count>
      <attachid>125509</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-04 18:01:39 -0800</bug_when>
    <thetext>Created attachment 125509
Fixes the bug</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>549508</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-04 18:04:10 -0800</bug_when>
    <thetext>It appears that making a reduction from html5-full-parser.html is pretty hard :( Maybe we can add it to LayoutTests as well as a crash-test?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>549509</commentid>
    <comment_count>4</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-04 18:25:05 -0800</bug_when>
    <thetext>http://code.google.com/p/chromium/issues/detail?id=112731</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>549510</commentid>
    <comment_count>5</comment_count>
      <attachid>125509</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-04 18:25:44 -0800</bug_when>
    <thetext>Comment on attachment 125509
Fixes the bug

Apparently our fuzz cluster had been finding crashes due to this bug. I&apos;ll add a test case using that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>549514</commentid>
    <comment_count>6</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-04 18:49:07 -0800</bug_when>
    <thetext>Actually, this isn&apos;t a use-after-free since CSSFontSelector accesses CachedResourceLoader through Document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>549530</commentid>
    <comment_count>7</comment_count>
      <attachid>125509</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-04 21:57:44 -0800</bug_when>
    <thetext>Comment on attachment 125509
Fixes the bug

I&apos;m sorry but turning this file into a DRT test appears to be really hard :( There appears to be some race condition in triggering this bug and it doesn&apos;t reproduce reliably in DRT. Also calling notifyDone or document.write or assigning some value to innerHTML/innerText also seem to make the test case not work :( I also tried embedding it inside an iframe and reload it several times but that doesn&apos;t seem to work either.

&lt;script&gt;
function check () {
 var mylink = document.getElementsByTagName(&apos;a&apos;);
 location =  mylink[0];
}
&lt;/script&gt;&lt;style&gt;@font-face { font-family: &quot;A&quot;; src: url(); }* { font-family: A;&lt;/style&gt;
&lt;body onload=&quot;check()&quot;&lt;linearGradient&gt;A00A00A000AA0AA00AA0&lt;a&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>549553</commentid>
    <comment_count>8</comment_count>
      <attachid>125509</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-02-05 00:34:41 -0800</bug_when>
    <thetext>Comment on attachment 125509
Fixes the bug

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

&gt; Source/WebCore/ChangeLog:11
&gt; +        No new tests but PerformanceTests/Parser/html5-full-render.html was crashing
&gt; +        on performance bots due to this bug.

Can we write an explicit LayoutTest for this crash?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>549554</commentid>
    <comment_count>9</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-02-05 00:36:20 -0800</bug_when>
    <thetext>Ah, I didn&apos;t see the earlier discussion.  Nate might have some ideas about how to write a reliable test.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>550303</commentid>
    <comment_count>10</comment_count>
    <who name="Lucas Forschler">lforschler</who>
    <bug_when>2012-02-06 14:44:12 -0800</bug_when>
    <thetext>&lt;rdar://problem/10815525&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>552583</commentid>
    <comment_count>11</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-08 16:07:47 -0800</bug_when>
    <thetext>japhet told me that he had tried to make a reduction but was unable to. At this point, I&apos;d like to ask reviewers to have a look at my patch again. The fix is self-evidently correct as far as I&apos;m concerned.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>553376</commentid>
    <comment_count>12</comment_count>
      <attachid>125509</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-02-09 11:51:01 -0800</bug_when>
    <thetext>Comment on attachment 125509
Fixes the bug

Sigh.  I&apos;m worried that shuffling around these shutdown events will cause other crashes.  Without adding tests, we don&apos;t know that we&apos;re continuously improving.  We could just be cycling through problems.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>553378</commentid>
    <comment_count>13</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-02-09 11:52:52 -0800</bug_when>
    <thetext>(In reply to comment #12)
&gt; (From update of attachment 125509 [details])
&gt; Sigh.  I&apos;m worried that shuffling around these shutdown events will cause other crashes.  Without adding tests, we don&apos;t know that we&apos;re continuously improving.  We could just be cycling through problems.

I know. Hopefully the comment there makes it clear that we need to destroy clearStyleSelector first. In the long term, we really need to come up with a better mechanism to test the loader code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>553744</commentid>
    <comment_count>14</comment_count>
      <attachid>125509</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-02-09 19:34:37 -0800</bug_when>
    <thetext>Comment on attachment 125509
Fixes the bug

Clearing flags on attachment: 125509

Committed r107346: &lt;http://trac.webkit.org/changeset/107346&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>553745</commentid>
    <comment_count>15</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-02-09 19:34:43 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>125509</attachid>
            <date>2012-02-04 18:01:39 -0800</date>
            <delta_ts>2012-02-09 19:34:37 -0800</delta_ts>
            <desc>Fixes the bug</desc>
            <filename>bug-77817-20120204180137.patch</filename>
            <type>text/plain</type>
            <size>1698</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDEwNjc1MikKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE4IEBACisyMDEyLTAyLTA0ICBSeW9zdWtl
IE5pd2EgI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wLDcgKzU0MCw2IEBAIERvY3VtZW50Ojp+RG9jdW1lbnQo
KQogICAgIEFTU0VSVCghbV9wYXJzZXIgfHwgbV9wYXJzZXItPnJlZkNvdW50KCkgPT0gMSk7CiAg
ICAgZGV0YWNoUGFyc2VyKCk7CiAgICAgbV9kb2N1bWVudCA9IDA7Ci0gICAgbV9jYWNoZWRSZXNv
dXJjZUxvYWRlci5jbGVhcigpOwogCiAgICAgbV9yZW5kZXJBcmVuYS5jbGVhcigpOwogCkBAIC01
NzMsNiArNTcyLDkgQEAgRG9jdW1lbnQ6On5Eb2N1bWVudCgpCiAgICAgaWYgKG1fbWVkaWFRdWVy
eU1hdGNoZXIpCiAgICAgICAgIG1fbWVkaWFRdWVyeU1hdGNoZXItPmRvY3VtZW50RGVzdHJveWVk
KCk7CiAKKyAgICBjbGVhclN0eWxlU2VsZWN0b3IoKTsgLy8gV2UgbmVlZCB0byBkZXN0b3J5IENT
U0ZvbnRTZWxlY3RvciBiZWZvcmUgZGVzdHJveWluZyBtX2NhY2hlZFJlc291cmNlTG9hZGVyLgor
ICAgIG1fY2FjaGVkUmVzb3VyY2VMb2FkZXIuY2xlYXIoKTsKKwogICAgIC8vIFdlIG11c3QgY2Fs
bCBjbGVhclJhcmVEYXRhKCkgaGVyZSBzaW5jZSBhIERvY3VtZW50IGNsYXNzIGluaGVyaXRzIFRy
ZWVTY29wZQogICAgIC8vIGFzIHdlbGwgYXMgTm9kZS4gU2VlIGEgY29tbWVudCBvbiBUcmVlU2Nv
cGUuaCBmb3IgdGhlIHJlYXNvbi4KICAgICBpZiAoaGFzUmFyZURhdGEoKSkK
</data>

          </attachment>
      

    </bug>

</bugzilla>