<?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>186221</bug_id>
          
          <creation_ts>2018-06-01 20:22:16 -0700</creation_ts>
          <short_desc>throw/catch(e) abandons a Document</short_desc>
          <delta_ts>2018-06-04 14:45:54 -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>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>186277</dup_id>
          
          <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="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>ggaren</cc>
    
    <cc>keith_miller</cc>
    
    <cc>koivisto</cc>
    
    <cc>mark.lam</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1429487</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-06-01 20:22:16 -0700</bug_when>
    <thetext>If you load LayoutTests/fast/css/invalid-import-rule-insertion.html, then load another page and clear the page cache, the Document for LayoutTests/fast/css/invalid-import-rule-insertion.html is never released. It seems to be trapped in a retain cycle.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1429488</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-06-01 20:22:33 -0700</bug_when>
    <thetext>&lt;rdar://problem/40743441&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1429492</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-06-01 20:36:47 -0700</bug_when>
    <thetext>This is triggered by the throw and a catch that references the exception. Minimal test case: 

&lt;script&gt;
    try
    {
        throw(&apos;The document is abandoned&apos;);
    }
    catch(e)
    {
    }
&lt;/script&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1429497</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-06-01 20:55:59 -0700</bug_when>
    <thetext>My heap inspector tool shows a reference chain thus:

Exception (GC root—VM exceptions) -&gt; Internal -&gt; 
ProgramCodeBlock  -&gt;  Internal -&gt; 
Window  -&gt; Variable document  -&gt; 
HTMLDocument  “file:///Volumes/Data/Development/apple/webkit/OpenSource/LayoutTests/fast/css/invalid-import-rule-insertion.html”

m_vm-&gt;lastException() is a GC root (see slotVisitor.appendUnbarriered(m_vm-&gt;lastException()) in Heap.cpp).

Seems like we should clear this at some point.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1429498</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-06-01 20:58:29 -0700</bug_when>
    <thetext>I guess we clear lastException() next time we run script (in the VMEntryScope constructor).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1429503</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-06-01 21:26:44 -0700</bug_when>
    <thetext>Maybe GCController should call clearLastException() in some code paths.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1429570</commentid>
    <comment_count>6</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2018-06-02 09:49:42 -0700</bug_when>
    <thetext>Two promising places to clear lastException:

(1) ~JSLock()

(2) A zero-delay timer

The purpose of lastException is to provide an out-of-band accessor to the exception thrown by the current task / micro task. So, it&apos;s OK to throw it away after the task / micro task ends.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1429909</commentid>
    <comment_count>7</comment_count>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2018-06-04 14:45:54 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 186277 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>