<HTML><BODY><div>Hi, Sergey!</div><div>LGTM, except for a few nits regarding the commit message.</div><div> </div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div> <blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16760343200456828543_BODY">From: Mike Pall <mike><br><br>Reported by Alex Orlenko.<br><br>(cherry picked from commit b4b2dce9fc3ffaaaede39b36d06415311e2aa516)<br><br>The `pcall()` assembler preambule modifies `RC` (`x28`) (N args * 8)</div></div></div></div></blockquote><div>The «`RC` (`x28`) (N args * 8)» expression is hard to percieve. I suggest</div><div>reformulating it in a way like «modifies `RC`, which is mapped to `x28`, so</div><div>it has value ...». Feel free to ignore.</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>during the check of the amount of the given arguments. So, this wrong<br>value using in the `fff_fallback` routine leading to a crash on the</div></div></div></div></blockquote><div>Typo: s/using/being used/</div><div>Typo: s/leading/leads</div><div>Typo: s/on the/on</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>error throwing, because the Lua stack is filled incorrect and can't be</div></div></div></div></blockquote><div>Typo: s/is filled incorrect/is incorrectly filled/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>unwound.<br><br>This patch adds the additional comparison before taking the fallback<br>branch and modifies `RC` only after this branch.<br><br>Sergey Kaplun:<br>* added the description and the test for the problem<br><br>Part of tarantool/tarantool#8069<br>---<br><br>PR: <a href="https://github.com/tarantool/tarantool/pull/8295" target="_blank">https://github.com/tarantool/tarantool/pull/8295</a><br>Branch: <a href="https://github.com/tarantool/luajit/tree/skaplun/lj-762-arm64-pcall-no-arg" target="_blank">https://github.com/tarantool/luajit/tree/skaplun/lj-762-arm64-pcall-no-arg</a><br>Issues:<br>* <a href="https://github.com/tarantool/tarantool/issues/8069" target="_blank">https://github.com/tarantool/tarantool/issues/8069</a><br>* <a href="https://github.com/LuaJIT/LuaJIT/issues/762" target="_blank">https://github.com/LuaJIT/LuaJIT/issues/762</a><br><br> src/vm_arm64.dasc | 3 ++-<br> test/tarantool-tests/lj-762-pcall-no-arg.test.lua | 15 +++++++++++++++<br> 2 files changed, 17 insertions(+), 1 deletion(-)<br> create mode 100644 test/tarantool-tests/lj-762-pcall-no-arg.test.lua<br><br>diff --git a/src/vm_arm64.dasc b/src/vm_arm64.dasc<br>index f517a808..e8b63d33 100644<br>--- a/src/vm_arm64.dasc<br>+++ b/src/vm_arm64.dasc<br>@@ -1168,9 +1168,10 @@ static void build_subroutines(BuildCtx *ctx)<br>   |//-- Base library: catch errors ----------------------------------------<br>   |<br>   |.ffunc pcall<br>+ | cmp NARGS8:RC, #8<br>   | ldrb TMP0w, GL->hookmask<br>- | subs NARGS8:RC, NARGS8:RC, #8<br>   | blo ->fff_fallback<br>+ | sub NARGS8:RC, NARGS8:RC, #8<br>   | mov RB, BASE<br>   | add BASE, BASE, #16<br>   | ubfx TMP0w, TMP0w, #HOOK_ACTIVE_SHIFT, #1<br>diff --git a/test/tarantool-tests/lj-762-pcall-no-arg.test.lua b/test/tarantool-tests/lj-762-pcall-no-arg.test.lua<br>new file mode 100644<br>index 00000000..6cbfe707<br>--- /dev/null<br>+++ b/test/tarantool-tests/lj-762-pcall-no-arg.test.lua<br>@@ -0,0 +1,15 @@<br>+local tap = require('tap')<br>+<br>+-- Test file to check error raising for `pcall()` without<br>+-- arguments. Regardless that the problem is aarch64-specific,<br>+-- it is good to test it for all arches.<br>+-- See also <a href="https://github.com/LuaJIT/LuaJIT/issues/762" target="_blank">https://github.com/LuaJIT/LuaJIT/issues/762</a>.<br>+local test = tap.test('lj-762-pcall-no-arg')<br>+test:plan(2)<br>+<br>+local result, err = pcall(pcall)<br>+<br>+test:ok(not result, 'pcall() without args: bad status')<br>+test:like(err, 'value expected', 'pcall() without args: error message')<br>+<br>+os.exit(test:check() and 0 or 1)<br>--<br>2.34.1</div></div></div></div></blockquote><div><div>--<br>Best regards,</div><div>Maxim Kokryashkin</div></div><div> </div></div></blockquote></BODY></HTML>