<?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>149027</bug_id>
          
          <creation_ts>2015-09-09 18:48:03 -0700</creation_ts>
          <short_desc>JSInternalPromiseDeferred should inherit JSPromiseDeferred</short_desc>
          <delta_ts>2015-09-10 11:05:08 -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>New Bugs</component>
          <version>WebKit 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></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yusuke Suzuki">ysuzuki</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>darin</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>saam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1124798</commentid>
    <comment_count>0</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-09-09 18:48:03 -0700</bug_when>
    <thetext>JSInternalPromiseDeferred should inherit JSPromiseDeferred</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1124799</commentid>
    <comment_count>1</comment_count>
      <attachid>260902</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-09-09 18:50:46 -0700</bug_when>
    <thetext>Created attachment 260902
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1124800</commentid>
    <comment_count>2</comment_count>
      <attachid>260902</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-09-09 18:52:27 -0700</bug_when>
    <thetext>Comment on attachment 260902
Patch

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

&gt; Source/JavaScriptCore/runtime/JSInternalPromiseDeferred.cpp:41
&gt; +const ClassInfo JSInternalPromiseDeferred::s_info = { &quot;JSInternalPromiseDeferred&quot;, &amp;Base::s_info, nullptr, CREATE_METHOD_TABLE(JSInternalPromiseDeferred) };

While JSPromiseDeferred does not inherit anything, JSInternalPromiseDeferred inherits JSPromiseDeferred.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1124829</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-09-09 21:18:50 -0700</bug_when>
    <thetext>*** Bug 149028 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1124830</commentid>
    <comment_count>4</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-09-09 21:33:38 -0700</bug_when>
    <thetext>When visitChildren is called, since we perform jsCast&lt;JSPromiseDeferred*&gt;(cell), it causes the crash.

But it is difficult to reproduce this situation stably in the JSC shell because JSInternalPromiseDeferred is not held by the reachable objects.

The situation is the following,

(1): When JSInternalPromiseDeferred is created and resides on the C stack,
(2): GC starts
(3): GC calls visitChildren of JSInternalPromiseDeferred object
(4): perform jsCast&lt;JSPromiseDeferred*&gt;(cell) and crash.

So this patch does not contain the tests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1124834</commentid>
    <comment_count>5</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-09-09 21:43:18 -0700</bug_when>
    <thetext>These faults are figured out during the ES6 Module WebCore integration.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1124902</commentid>
    <comment_count>6</comment_count>
      <attachid>260902</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2015-09-10 08:45:10 -0700</bug_when>
    <thetext>Comment on attachment 260902
Patch

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

&gt;&gt; Source/JavaScriptCore/runtime/JSInternalPromiseDeferred.cpp:41
&gt;&gt; +const ClassInfo JSInternalPromiseDeferred::s_info = { &quot;JSInternalPromiseDeferred&quot;, &amp;Base::s_info, nullptr, CREATE_METHOD_TABLE(JSInternalPromiseDeferred) };
&gt; 
&gt; While JSPromiseDeferred does not inherit anything, JSInternalPromiseDeferred inherits JSPromiseDeferred.

I am confused about test coverage. Is there a reason we don’t have a test that demonstrates the problem this lack of inheritance causes?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1124945</commentid>
    <comment_count>7</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-09-10 10:56:13 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; Comment on attachment 260902 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=260902&amp;action=review
&gt; 
&gt; &gt;&gt; Source/JavaScriptCore/runtime/JSInternalPromiseDeferred.cpp:41
&gt; &gt;&gt; +const ClassInfo JSInternalPromiseDeferred::s_info = { &quot;JSInternalPromiseDeferred&quot;, &amp;Base::s_info, nullptr, CREATE_METHOD_TABLE(JSInternalPromiseDeferred) };
&gt; &gt; 
&gt; &gt; While JSPromiseDeferred does not inherit anything, JSInternalPromiseDeferred inherits JSPromiseDeferred.
&gt; 
&gt; I am confused about test coverage. Is there a reason we don’t have a test
&gt; that demonstrates the problem this lack of inheritance causes?

This case is a little bit edge case I think.
For the usual classes, I think we will see the assertion failure with the existing test cases.
But, JSInternalPromiseDeferred does not cause it before prototyping Module Loader in WebCore. This is because,

1. This fault causes error when executing JSInternalPromiseDeferred&apos;s visitChildren. Since it utilizes JSPromiseDeferred&apos;s one, this function attempt to perform jsCast&lt;JSPromiseDeferred*&gt;(cell). So, if we forgot to inherit JSPromiseDeferred::classInfo, it causes assertion failure.
2. But visitChildren is only called when the target object is live and GC occurs
3. JSInternalPromiseDeferred is only used in C++ runtime layer now. And it will be discarded relatively soon.
4. So, the problem only occurs when JSInternalPromiseDeferred is live in the C stack and GC occurs.
5. In addition to this limited situation, JSInternalPromiseDeferred is now only used for the module loader. So it only used when loading modules.

The above reasons make testing harder.
Hopefully, I this we will cover this bug.
I found this issue while prototyping the module loader in WebCore, this is because,

1. In JSC shell module loader, we fetch the module source code from the local file system. So the source code is immediately fetched. In this case, we don&apos;t need to hold JSInternalPromiseDeferred because we can resolve the promise with the fetched source immediately. So JSInternalPromiseDeferred will be discarded soon.
2. But in WebCore side, the source code will be fetched over the network. So until we fetched the source code, we need to strongly hold the JSInternalPromiseDeferred instance to resolve the promise when the source is fetched.
3. So, we keep JSInternalPromiseDeferred alive for a while. If the GC occurs during this, we can see this assertion failure.

So I think we can cover the problem solved here when adding the tests for the WebCore integrated module loader (I&apos;m now implementing it).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1124949</commentid>
    <comment_count>8</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2015-09-10 11:05:08 -0700</bug_when>
    <thetext>Committed r189577: &lt;http://trac.webkit.org/changeset/189577&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>260902</attachid>
            <date>2015-09-09 18:50:46 -0700</date>
            <delta_ts>2015-09-10 08:45:10 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-149027-20150909185039.patch</filename>
            <type>text/plain</type>
            <size>1684</size>
            <attacher name="Yusuke Suzuki">ysuzuki</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTg5NTYzCmRpZmYgLS1naXQgYS9Tb3VyY2UvSmF2YVNj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
R2xvYmFsT2JqZWN0KiBnbG9iYWxPYmplY3QpCiB7Cg==
</data>
<flag name="review"
          id="286106"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>