<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#c14">Comment # 14</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:sbarati&#64;apple.com" title="Saam Barati &lt;sbarati&#64;apple.com&gt;"> <span class="fn">Saam Barati</span></a>
</span></b>
        <pre>(In reply to Carlos Garcia Campos from <a href="show_bug.cgi?id=170390#c12">comment #12</a>)
<span class="quote">&gt; (In reply to Saam Barati from <a href="show_bug.cgi?id=170390#c9">comment #9</a>)
&gt; &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; &gt; Updated patch
&gt; &gt; 
&gt; &gt; View in context:
&gt; &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;&gt;&gt; Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.cpp:94
&gt; &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;&gt;&gt; Why not plan=WTFMove(plan)?
&gt; &gt; &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; &gt;&gt; RefPtr&lt;Plan&gt; plan = makeRef(p);
&gt; &gt; &gt;&gt; [plan = WTFMove(plan)]
&gt; &gt; &gt;&gt; 
&gt; &gt; &gt;&gt; is equivalent to 
&gt; &gt; &gt;&gt; 
&gt; &gt; &gt;&gt; [plan = makeRefPtr(p)]
&gt; &gt; &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; &gt; &gt; Gotcha. I see what's going on.
&gt; &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; &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; 
&gt; &gt; Seems like you could also keep the code as is, and just use p.vm() instead
&gt; &gt; of plan-&gt;vm().
&gt; 
&gt; Yes, that's my first patch see <a href="show_bug.cgi?id=170390#c1">comment #1</a></span >
I like your first patch. I'm not sure what the semantics are here of your capture of plan, since you don't define another variable named &quot;plan&quot;. Anyways, I'm worried about a reference cycle, which is why I like an explicit local variable. See the comment in WasmPlan.h.
<span class="quote">&gt; 
&gt; &gt; Also, I'm not sure why we make a RefPtr instead of a Ref here.
&gt; 
&gt; I think it's because then we end up doing Ref&lt;&gt; foo = Ref(); and Ref(const
&gt; Ref&amp; other) is deleted.</span >
Why not just do:
Ref&lt;Plan&gt; plan(p);
?</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>