<html>
    <head>
      <base href="https://bugs.webkit.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WebAssembly: several tests added in r214504 crash when building with GCC"
   href="https://bugs.webkit.org/show_bug.cgi?id=170390#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WebAssembly: several tests added in r214504 crash when building with GCC"
   href="https://bugs.webkit.org/show_bug.cgi?id=170390">bug 170390</a>
              from <span class="vcard"><a class="email" href="mailto:cgarcia&#64;igalia.com" title="Carlos Garcia Campos &lt;cgarcia&#64;igalia.com&gt;"> <span class="fn">Carlos Garcia Campos</span></a>
</span></b>
        <pre>(In reply to Saam Barati from <a href="show_bug.cgi?id=170390#c9">comment #9</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=306063&amp;action=diff" name="attach_306063" title="Updated patch">attachment 306063</a> <a href="attachment.cgi?id=306063&amp;action=edit" title="Updated patch">[details]</a></span>
&gt; Updated patch
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=306063&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=306063&amp;action=review</a>
&gt; 
&gt; &gt;&gt;&gt;&gt; Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.cpp:94
&gt; &gt;&gt;&gt;&gt; +        p.vm().promiseDeferredTimer-&gt;scheduleWorkSoon(promise, [source, promise, globalObject, plan = makeRefPtr(p)] () mutable {
&gt; &gt;&gt;&gt; 
&gt; &gt;&gt;&gt; Why not plan=WTFMove(plan)?
&gt; &gt;&gt; 
&gt; &gt;&gt; Because I've removed the line that created the plan to simplify it. 
&gt; &gt;&gt; 
&gt; &gt;&gt; RefPtr&lt;Plan&gt; plan = makeRef(p);
&gt; &gt;&gt; [plan = WTFMove(plan)]
&gt; &gt;&gt; 
&gt; &gt;&gt; is equivalent to 
&gt; &gt;&gt; 
&gt; &gt;&gt; [plan = makeRefPtr(p)]
&gt; &gt;&gt; 
&gt; &gt;&gt; I think this way is simpler, since we were only creating the plan to transfer it to the lambda capture (and to get the vm, but that is what caused the crash).
&gt; &gt; 
&gt; &gt; Gotcha. I see what's going on.
&gt; &gt; I still think you need a local variable for the plan, otherwise, won't the lambda capture the outermost plan? I think that'll lead to a reference cycle.
&gt; &gt; Even if that assignment doesn't cause this to happen, I think it's harder to reason about than just having a local variable.
&gt; 
&gt; Seems like you could also keep the code as is, and just use p.vm() instead
&gt; of plan-&gt;vm().</span >

Yes, that's my first patch see <a href="show_bug.cgi?id=170390#c1">comment #1</a>

<span class="quote">&gt; Also, I'm not sure why we make a RefPtr instead of a Ref here.</span >

I think it's because then we end up doing Ref&lt;&gt; foo = Ref(); and Ref(const Ref&amp; other) is deleted.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>