<?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>44170</bug_id>
          
          <creation_ts>2010-08-18 06:21:16 -0700</creation_ts>
          <short_desc>HTML5 TreeBuilder ASSERTs on &lt;a&gt;&lt;svg&gt;&lt;tr&gt;&lt;input&gt;&lt;/a&gt;</short_desc>
          <delta_ts>2010-08-21 20:07:15 -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>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P1</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>43055</dependson>
    
    <dependson>44129</dependson>
          <blocked>44390</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Berend-Jan Wever">skylined</reporter>
          <assigned_to name="Tony Gentilcore">tonyg</assigned_to>
          <cc>abarth</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>eric</cc>
    
    <cc>inferno</cc>
    
    <cc>sam</cc>
    
    <cc>tonyg</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>266072</commentid>
    <comment_count>0</comment_count>
      <attachid>64697</attachid>
    <who name="Berend-Jan Wever">skylined</who>
    <bug_when>2010-08-18 06:21:16 -0700</bug_when>
    <thetext>Created attachment 64697
Repro

The following repro causes memory corruption in Chromium:
&lt;body onload=&quot;
  document.writeln(&apos;&lt;a &gt;&lt;svg &gt;&lt;tr/s&gt;&lt;input&gt;&lt;/a&gt;&apos;);
  document.open();
&quot;&gt;
Crashes vary wildly, but most commonly I see a crash in 
WebCore::removeAllChildrenInContainer&lt;WebCore::Node,WebCore::ContainerNode&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266140</commentid>
    <comment_count>1</comment_count>
    <who name="Abhishek Arya">inferno</who>
    <bug_when>2010-08-18 09:04:21 -0700</bug_when>
    <thetext>Adding security as product.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266143</commentid>
    <comment_count>2</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-08-18 09:08:44 -0700</bug_when>
    <thetext>I feel like this is identical to another one you filed this morning.  Like bug 44172.

These are probably all related to/duplicates of bug 43055.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266145</commentid>
    <comment_count>3</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2010-08-18 09:09:33 -0700</bug_when>
    <thetext>&lt;rdar://problem/8324425&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266151</commentid>
    <comment_count>4</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-08-18 09:11:19 -0700</bug_when>
    <thetext>I&apos;ll be landing a fix for bug 43055 this afternoon, then I can look at some of these others.  I suspect most of them will be dupes. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266157</commentid>
    <comment_count>5</comment_count>
    <who name="Abhishek Arya">inferno</who>
    <bug_when>2010-08-18 09:20:45 -0700</bug_when>
    <thetext>Eric, this bug reproduces with just

&lt;a&gt;&lt;svg&gt;&lt;tr&gt;&lt;input&gt;&lt;/a&gt; and pressing page reload. It hits this assert without reload. I am taking a closer look now, dont think it is related to 43055.

ASSERT(!newChild-&gt;parent()); // Use appendChild if you need to handle reparenting.

 WebCore::ContainerNode::addChildCommon(WebCore::Node * newChild=0x08153780)  Line 539 + 0x2b bytes
 WebCore::ContainerNode::parserAddChild(WTF::PassRefPtr&lt;WebCore::Node&gt; newChild={m_document=0x08219000 m_previous=0x00000000 m_next=0x00000000 ...})  Line 559
 WebCore::HTMLConstructionSite::attachAtSite(const WebCore::HTMLConstructionSite::AttachmentSite &amp; site={...}, WTF::PassRefPtr&lt;WebCore::Node&gt; prpChild=NULL)  Line 133
 WebCore::HTMLConstructionSite::fosterParent(WebCore::Node * node=0x08153780)  Line 457
 WebCore::HTMLTreeBuilder::callTheAdoptionAgency(WebCore::AtomicHTMLToken &amp; token={...})  Line 1835
 WebCore::HTMLTreeBuilder::processEndTagForInBody(WebCore::AtomicHTMLToken &amp; token={...})  Line 2161
 WebCore::HTMLTreeBuilder::processEndTag(WebCore::AtomicHTMLToken &amp; token={...})  Line 2295
 WebCore::HTMLTreeBuilder::processToken(WebCore::AtomicHTMLToken &amp; token={...})  Line 629
 WebCore::HTMLTreeBuilder::processUsingSecondaryInsertionModeAndAdjustInsertionMode(WebCore::AtomicHTMLToken &amp; token={...})  Line 2539
 WebCore::HTMLTreeBuilder::processEndTag(WebCore::AtomicHTMLToken &amp; token={...})  Line 2499
 WebCore::HTMLTreeBuilder::processToken(WebCore::AtomicHTMLToken &amp; token={...})  Line 629
 WebCore::HTMLTreeBuilder::constructTreeFromToken(WebCore::HTMLToken &amp; rawToken={...})  Line 612
 WebCore::HTMLDocumentParser::pumpTokenizer(WebCore::HTMLDocumentParser::SynchronousMode mode=AllowYield)  Line 196
 WebCore::HTMLDocumentParser::pumpTokenizerIfPossible(WebCore::HTMLDocumentParser::SynchronousMode mode=AllowYield)  Line 151
 WebCore::HTMLDocumentParser::append(const WebCore::SegmentedString &amp; source={...})  Line 282
 WebCore::DecodedDataDocumentParser::appendBytes(WebCore::DocumentWriter * writer=0x0508b18c, const char * data=0x00000000, int length=0, bool shouldFlush=true)  Line 55 + 0x1f bytes
 WebCore::DocumentWriter::addData(const char * str=0x00000000, int len=0, bool flush=true)  Line 200 + 0x20 bytes
 WebCore::DocumentWriter::endIfNotLoadingMainResource()  Line 221
 WebCore::DocumentWriter::end()  Line 207
 WebCore::DocumentLoader::finishedLoading()  Line 270
 WebCore::FrameLoader::finishedLoading()  Line 2160</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266159</commentid>
    <comment_count>6</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-08-18 09:26:55 -0700</bug_when>
    <thetext>Sweet!  A new test for the parser.

No one has shipped this.  I&apos;m not sure this needs to be a security bug.  Adam, Tony or I will have a patch landed this afternoon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266162</commentid>
    <comment_count>7</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-08-18 09:30:28 -0700</bug_when>
    <thetext>Thanks again for the test case!

This is obviously security related, but doesn&apos;t need to be marked sensitive since this code has not (and will not) ship as is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266164</commentid>
    <comment_count>8</comment_count>
    <who name="Abhishek Arya">inferno</who>
    <bug_when>2010-08-18 09:37:18 -0700</bug_when>
    <thetext>Thanks Eric, Adam, Tony for taking care of it. 

Another security bug off our radar :) Marking it security helps to keep track, but since i am on the cc, i will update chromium side bug when it gets fixed - http://code.google.com/p/chromium/issues/detail?id=52581.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266171</commentid>
    <comment_count>9</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-08-18 09:46:40 -0700</bug_when>
    <thetext>I suspect we&apos;ll find a number of edge-cases like this in the new tree builder.  They&apos;ll be simple to fix (unlike the old tree builder), but I expect there may be a bunch, so I&apos;m glad you&apos;re fuzzing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266329</commentid>
    <comment_count>10</comment_count>
    <who name="Tony Gentilcore">tonyg</who>
    <bug_when>2010-08-18 13:05:37 -0700</bug_when>
    <thetext>Eric and I chatted about this briefly on IRC. I&apos;ll take a look.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266394</commentid>
    <comment_count>11</comment_count>
    <who name="Tony Gentilcore">tonyg</who>
    <bug_when>2010-08-18 14:53:08 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; Eric and I chatted about this briefly on IRC. I&apos;ll take a look.

I&apos;m releasing this bug for now so that I can focus on 44129 (which turned out to be more involved than I thought).

Eric, if you don&apos;t get to this first, I&apos;m happy to pick it up again.

Here are my notes so far:

TreeBuilder has this branch:
if causesFosterParenting
  tree.fosterParent()
else
  commonAncestor.appendChild()

This case takes the fosterParent() route for the &lt;svg&gt; element which invokes attachAtSite() and calls parserAddChild(). That method doesn&apos;t handle reparenting.

Changing parserAddChild() to appendChild() fixes the crash because it handles reparenting. However, I&apos;m positive that is not the solution in light of our discussion of mutation events. Perhaps the answer is to teach parserAddChild() about reparenting or in some other way address the FIXME in attach() about attachAtSite() not handling foster parenting.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266837</commentid>
    <comment_count>12</comment_count>
    <who name="Tony Gentilcore">tonyg</who>
    <bug_when>2010-08-19 11:09:06 -0700</bug_when>
    <thetext>It is looking like a single patch that reparents in AAA step 7 and uses parser* methods for insertBefore, removeChild, addChild will fix this and 44129.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>267497</commentid>
    <comment_count>13</comment_count>
    <who name="Tony Gentilcore">tonyg</who>
    <bug_when>2010-08-20 17:28:54 -0700</bug_when>
    <thetext>Crash fixed by r65769.

The dom tree doesn&apos;t seem right. Filed spec bug here:
http://www.w3.org/Bugs/Public/show_bug.cgi?id=10409</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>64697</attachid>
            <date>2010-08-18 06:21:16 -0700</date>
            <delta_ts>2010-08-18 06:21:16 -0700</delta_ts>
            <desc>Repro</desc>
            <filename>repro.html</filename>
            <type>text/html</type>
            <size>88</size>
            <attacher name="Berend-Jan Wever">skylined</attacher>
            
              <data encoding="base64">PGJvZHkgb25sb2FkPSIKICBkb2N1bWVudC53cml0ZWxuKCc8YSA+PHN2ZyA+PHRyL3M+PGlucHV0
PjwvYT4nKTsKICBkb2N1bWVudC5vcGVuKCk7CiI+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>