<?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>67487</bug_id>
          
          <creation_ts>2011-09-02 07:27:26 -0700</creation_ts>
          <short_desc>Case of the missing shadow Tree</short_desc>
          <delta_ts>2012-05-21 13:44:34 -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>SVG</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows Vista</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P1</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Berend-Jan Wever">skylined</reporter>
          <assigned_to name="Stephen Chenney">schenney</assigned_to>
          <cc>dglazkov</cc>
    
    <cc>eric</cc>
    
    <cc>krit</cc>
    
    <cc>leandro</cc>
    
    <cc>schenney</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>461215</commentid>
    <comment_count>0</comment_count>
      <attachid>106130</attachid>
    <who name="Berend-Jan Wever">skylined</who>
    <bug_when>2011-09-02 07:27:26 -0700</bug_when>
    <thetext>Created attachment 106130
Repro

Repro:
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; xmlns:x=&quot;x&quot;&gt;
  &lt;foreignObject id=&quot;foreignObject&quot;&gt;
    &lt;x:div id=&quot;x&quot;&gt;&lt;/x:div&gt;
  &lt;/foreignObject&gt;
  &lt;use id=&quot;use&quot; xlink:href=&quot;#foreignObject&quot; /&gt;
  &lt;use xlink:href=&quot;#use&quot;/&gt;
  &lt;script&gt;
    document.documentElement.insertBefore(document.getElementById(&quot;x&quot;));
  &lt;/script&gt;
&lt;/svg&gt;

Not sure what happens exactly, but the foreignObject element ends up with a NULL shadow tree element, which triggers ASSERTS and a NULL ptr:

void SVGElementInstance::invalidateAllInstancesOfElement(SVGElement* element)
{
    if (!element || !element-&gt;inDocument())
        return;

    if (element-&gt;isStyled() &amp;&amp; static_cast&lt;SVGStyledElement*&gt;(element)-&gt;instanceUpdatesBlocked())
        return;

    const HashSet&lt;SVGElementInstance*&gt;&amp; set = element-&gt;instancesForElement();
    if (set.isEmpty())
        return;

    // Mark all use elements referencing &apos;element&apos; for rebuilding
    const HashSet&lt;SVGElementInstance*&gt;::const_iterator end = set.end();
    for (HashSet&lt;SVGElementInstance*&gt;::const_iterator it = set.begin(); it != end; ++it) {
        ASSERT((*it)-&gt;shadowTreeElement());
        ASSERT((*it)-&gt;shadowTreeElement()-&gt;correspondingElement());
        ASSERT((*it)-&gt;correspondingElement() == element);
        (*it)-&gt;shadowTreeElement()-&gt;setCorrespondingElement(0);
        if (SVGUseElement* element = (*it)-&gt;correspondingUseElement()) {
            ASSERT(element-&gt;inDocument());
            element-&gt;invalidateShadowTree();
        }
    }

    // Be sure to rebuild use trees, if needed
    element-&gt;document()-&gt;updateLayoutIgnorePendingStylesheets();
}

id:             chrome.dll!WebCore::SVGElement::ensureRareSVGData ReadAV@NULL (b5516c4ed1ba6200134db33c80c5ed49)
description:    Attempt to read from unallocated NULL pointer+0x27 in chrome.dll!WebCore::SVGElement::ensureRareSVGData
stack:          chrome.dll!WebCore::SVGElement::ensureRareSVGData
                chrome.dll!WebCore::SVGElement::setCorrespondingElement
                chrome.dll!WebCore::SVGElementInstance::invalidateAllInstancesOfElement
                chrome.dll!WebCore::SVGStyledElement::childrenChanged
                chrome.dll!WebCore::ContainerNode::removeChild
                chrome.dll!WebCore::ContainerNode::appendChild
                chrome.dll!WebCore::ContainerNode::insertBefore
                chrome.dll!WebCore::Node::insertBefore
                chrome.dll!WebCore::V8Node::insertBeforeCallback
                chrome.dll!v8::internal::HandleApiCallHelper&lt;...&gt;
                chrome.dll!v8::internal::Builtin_HandleApiCall
                chrome.dll!v8::internal::Invoke
                chrome.dll!v8::internal::Execution::Call
                ...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>461217</commentid>
    <comment_count>1</comment_count>
    <who name="Berend-Jan Wever">skylined</who>
    <bug_when>2011-09-02 07:29:10 -0700</bug_when>
    <thetext>Chromium: https://code.google.com/p/chromium/issues/detail?id=95201</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>629448</commentid>
    <comment_count>2</comment_count>
    <who name="Stephen Chenney">schenney</who>
    <bug_when>2012-05-21 13:44:34 -0700</bug_when>
    <thetext>This was fixed at some point and does not crash Chromium ToT. It does crash Chrome 19, but that does not have the fix in it, to my knowledge.

I believe the relevant changes are:

Initial patch: &lt;http://trac.webkit.org/changeset/109299&gt;
And follow up: &lt;http://trac.webkit.org/changeset/109333&gt;

These disallow foreign object inside a &lt;use&gt; element, as the spec demands.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>106130</attachid>
            <date>2011-09-02 07:27:26 -0700</date>
            <delta_ts>2011-09-02 07:27:26 -0700</delta_ts>
            <desc>Repro</desc>
            <filename>repro.svg</filename>
            <type>image/svg+xml</type>
            <size>379</size>
            <attacher name="Berend-Jan Wever">skylined</attacher>
            
              <data encoding="base64">PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRw
Oi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICA8Zm9yZWlnbk9iamVjdCBpZD0iZm9yZWlnbk9i
amVjdCI+CiAgICA8eC8+CiAgPC9mb3JlaWduT2JqZWN0PgogIDx1c2UgaWQ9InVzZSIgeGxpbms6
aHJlZj0iI2ZvcmVpZ25PYmplY3QiIC8+CiAgPHVzZSB4bGluazpocmVmPSIjdXNlIi8+CiAgPHNj
cmlwdD4KICAgIHZhciBvRm9yZWlnbk9iamVjdCA9IGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJm
b3JlaWduT2JqZWN0Iik7CiAgICBvRm9yZWlnbk9iamVjdC5yZW1vdmVDaGlsZChvRm9yZWlnbk9i
amVjdC5maXJzdENoaWxkKTsKICA8L3NjcmlwdD4KPC9zdmc+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>