<!DOCTYPE html>
<html data-lt-installed="true">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body style="padding-bottom: 1px;">
    <p>Bonjour, Sergey,</p>
    <p>fixed and force-pushed.</p>
    <p>Sergey<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 07.02.2025 13:50, Sergey Kaplun via
      Tarantool-patches wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:Z6XlXPIisc5Appmk@root">
      <pre class="moz-quote-pre" wrap="">Hi, Sergey!
Thanks for the fixes!
LGTM, after fixing a bunch of nits below.

On 06.02.25, Sergey Bronnikov wrote:
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">From: Mike Pall <mike>

</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
<snipped>

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">---
Branch: <a class="moz-txt-link-freetext" href="https://github.com/tarantool/luajit/tree/ligurio/lj-1087-vm-handler-call">https://github.com/tarantool/luajit/tree/ligurio/lj-1087-vm-handler-call</a>

Related issues:
- <a class="moz-txt-link-freetext" href="https://github.com/LuaJIT/LuaJIT/issues/1087">https://github.com/LuaJIT/LuaJIT/issues/1087</a>
- <a class="moz-txt-link-freetext" href="https://github.com/tarantool/tarantool/issues/10709">https://github.com/tarantool/tarantool/issues/10709</a>

Changes in the v2:
* Addressed comments by Sergey Kaplun

</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
<snipped>

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">diff --git a/src/lj_trace.c b/src/lj_trace.c
index 94cb27e5..6b97cc13 100644
--- a/src/lj_trace.c
+++ b/src/lj_trace.c
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
<snipped>

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">diff --git a/test/tarantool-c-tests/lj-1087-vm-handler-call.test.c b/test/tarantool-c-tests/lj-1087-vm-handler-call.test.c
new file mode 100644
index 00000000..ebdf63e1
--- /dev/null
+++ b/test/tarantool-c-tests/lj-1087-vm-handler-call.test.c
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
<snipped>

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">+/* XXX: Still need normal assert inside writer functions. */
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Minor: Since there is no writer function, I would rather use the
following wording:
| Still need normal assert for sanity checks.
</pre>
    </blockquote>
    Fixed.<br>
    <blockquote type="cite" cite="mid:Z6XlXPIisc5Appmk@root">
      <pre class="moz-quote-pre" wrap="">
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">+#undef NDEBUG
+#include <assert.h>
+
+/*
+ * Test file to demonstrate a segmentation fault, when C function
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Typo: s/C function/a C function/</pre>
    </blockquote>
    Fixed.<br>
    <blockquote type="cite" cite="mid:Z6XlXPIisc5Appmk@root">
      <pre class="moz-quote-pre" wrap="">

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">+ * is used as a VM handler in LuaJIT:
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Minor: `as a VM handler for trace events` is a little bit more verbose.
Feel free to ignore.
</pre>
    </blockquote>
    <p>Fixed.</p>
    <p> /*<br>
      - * Test file to demonstrate a segmentation fault, when C function<br>
      - * is used as a VM handler in LuaJIT:<br>
      + * Test file to demonstrate a segmentation fault, when a C<br>
      + * function is used as a VM handler for trace events in LuaJIT:<br>
        *<br>
        * Program received signal SIGSEGV, Segmentation fault.<br>
        * 0x000055555557e77d in trace_abort (J=0x7ffff7f9b6b8) at
      lj_trace.c:615<br>
    </p>
    <blockquote type="cite" cite="mid:Z6XlXPIisc5Appmk@root">
      <pre class="moz-quote-pre" wrap="">
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">+ *
+ * Program received signal SIGSEGV, Segmentation fault.
+ * 0x000055555557e77d in trace_abort (J=0x7ffff7f9b6b8) at lj_trace.c:615
+ * 615         lj_vmevent_send(L, TRACE,
+ * (gdb) bt
+ *
+ * See details in <a class="moz-txt-link-freetext" href="https://github.com/LuaJIT/LuaJIT/issues/1087">https://github.com/LuaJIT/LuaJIT/issues/1087</a>.
+ */
+
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
<snipped>

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">+  /*
+        * The number 32767 is `REF_DROP - REF_BIAS`.
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
It will be better to rephrase the next sentence.

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">                                                 See the commit
+        * 0fdf06b456e6 ("test: relax JIT setup in misc.getmetrics
+        * test") for the details.
+        */
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
I suggest the following comment.
| This is the maximum possible IR amount, so the trace is always
| aborted.

The amount of text to read is approximately the same, but we don't need
to look into the mysterious commit anymore. :)</pre>
    </blockquote>
    <p>Fixed.</p>
    <p>@@ -103,9 +103,9 @@ static int handle_cont_frame(void
      *test_state)<br>
              jit_attach(L, nop, "trace");<br>
       <br>
              /*<br>
      -        * The number 32767 is `REF_DROP - REF_BIAS`. See the
      commit<br>
      -        * 0fdf06b456e6 ("test: relax JIT setup in misc.getmetrics<br>
      -        * test") for the details.<br>
      +        * The number 32767 is `REF_DROP - REF_BIAS`. This is the<br>
      +        * maximum possible IR amount, so the trace is always<br>
      +        * aborted.<br>
               */<br>
    </p>
    <blockquote type="cite" cite="mid:Z6XlXPIisc5Appmk@root">
      <pre class="moz-quote-pre" wrap="">

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">+  int res = luaL_dostring(L, "jit.opt.start('minstitch=32767')");
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
<snipped>

</pre>
    </blockquote>
  </body>
  <lt-container></lt-container>
</html>