<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#c13">Comment # 13</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 JF Bastien from <a href="show_bug.cgi?id=170390#c10">comment #10</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; Also, I'm not sure why we make a RefPtr instead of a Ref here.
&gt; 
&gt; This weirdness is why I suggest getting VM, and then using it on this line.
&gt; The entire problem is using plan two ways on one line of code: once to get
&gt; to VM, once to lambda capture. Getting rid of one is an easy fix, lambda
&gt; capture can't go, so VM on another line seems like the right fix.</span >

I don't see anything weird in the current patch, TBH. But I'm fine with any other solution, either my first patch or adding another local variable for the VM or a combination of both using a local variable for VM, but using makeRefPtr directly in the lambda capture. All of them should work.</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>