<?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>140919</bug_id>
          
          <creation_ts>2015-01-26 19:21:34 -0800</creation_ts>
          <short_desc>WeakMap Object key expected to be garbage collected is not</short_desc>
          <delta_ts>2015-01-27 14:23:06 -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>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ggaren</cc>
    
    <cc>joepeck</cc>
    
    <cc>mark.lam</cc>
    
    <cc>timothy</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1064348</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-01-26 19:21:34 -0800</bug_when>
    <thetext>* SUMMARY
In a LayoutTest I am adding to test WeakMap, an Object I expected to be garbage collected is not. This reproduces 100% for me in Debug (x84_64) builds, but does not in Release builds on the same machine.

* STEPS TO REPRODUCE
1. shell&gt; run-webkit-tests --debug LayoutTests/inspector/model/remote-object-weak-collection.html
  =&gt; FAILURE

After these series of steps:

&gt; strongKey1 = {id:1};
&gt; strongKey2 = {id:2};
&gt; weakMap = new WeakMap;
&gt; 
&gt; GCController.collect();
&gt; weakMap.set(strongKey1, 1);
&gt; weakMap.set(strongKey2, 2);
&gt; GCController.collect();
&gt; delete window.strongKey1;
&gt; GCController.collect();
&gt; weakMap.set({id:3}, 3);
&gt; weakMap.set({id:4}, 4);
&gt; GCController.collect();
&gt; weakMap

I expect the temporary object {id:4} to be garbage collected, but it is not.

* RESULTS DIFF
--- Build/Debug/layout-test-results/inspector/model/remote-object-weak-collection-expected.txt
+++ Build/Debug/layout-test-results/inspector/model/remote-object-weak-collection-actual.txt
@@ -119,6 +119,31 @@
       &quot;value&quot;: 2,
       &quot;description&quot;: &quot;2&quot;
     }
+  },
+  {
+    &quot;key&quot;: {
+      &quot;type&quot;: &quot;object&quot;,
+      &quot;objectId&quot;: &quot;&lt;filtered&gt;&quot;,
+      &quot;className&quot;: &quot;Object&quot;,
+      &quot;description&quot;: &quot;Object&quot;,
+      &quot;preview&quot;: {
+        &quot;type&quot;: &quot;object&quot;,
+        &quot;description&quot;: &quot;Object&quot;,
+        &quot;lossless&quot;: true,
+        &quot;properties&quot;: [
+          {
+            &quot;name&quot;: &quot;id&quot;,
+            &quot;type&quot;: &quot;number&quot;,
+            &quot;value&quot;: &quot;4&quot;
+          }
+        ]
+      }
+    },
+    &quot;value&quot;: {
+      &quot;type&quot;: &quot;number&quot;,
+      &quot;value&quot;: 4,
+      &quot;description&quot;: &quot;4&quot;
+    }
   }
 ]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1064349</commentid>
    <comment_count>1</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-01-26 19:22:20 -0800</bug_when>
    <thetext>Even though the test reproduces in Debug builds, I have seen some objects that I expect to get released, not get released in Release builds. I just do not have a reliable way to reproduce that issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1064350</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2015-01-26 19:22:53 -0800</bug_when>
    <thetext>&lt;rdar://problem/19609705&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1064351</commentid>
    <comment_count>3</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-01-26 19:24:33 -0800</bug_when>
    <thetext>The test and inspector pieces have not landed yet. It is currently up for review on bug 122867.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1064654</commentid>
    <comment_count>4</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-01-27 14:23:06 -0800</bug_when>
    <thetext>Geoff and I debugged this for a bit, and it looks like this is okay. For one, eventually in the test the object does get cleaned up so long term that looks fine. But further investigation into why it was temporary alive, it looks like the object is alive because it is on the stack during collection. Adding a &quot;timeout&quot; between the map mutation and collection, the object goes away as expected!

Closing as behaves correctly.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>