Hi, Sergey!
Thanks for the patch! Please see the comment below.
Sergey
From: Mike Pall <mike> Thanks to Peter Cawley. (cherry picked from commit 14e2917e7ab3d6f043d6604298bfa66470c6f47d) Enabling and disabling wrapped C function mode [1] unconditionally changes the bytecode to `BC_FUCC[W] 0 0`. The first operand (RA) is unused for x86/x64 VMs, but other VMs use it like the minimum available stack slots required for the function call (`LUA_MINSTACK` by default on VM startup). Hence, these bytecode rewriting lead to the different timing of the STACKOV error being raised (before the call or during the invocation of the C function). This patch makes the behaviour consistent across VMs by modifying only the opcode without changing its operands. Hence the `LUA_MINSTACK` value of the first operand is preserved. [1]: https://luajit.org/ext_c_api.html#mode_wrapcfunc Sergey Kaplun: * added the description and the test for the problem Part of tarantool/tarantool#13442 --- Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1047-fix-funccw-arm64 Related issues: * https://github.com/LuaJIT/LuaJIT/issues/1047 * https://github.com/tarantool/tarantool/issues/13442 Side note: CI on macOS x86_64 is red due to runner issues. src/lj_dispatch.c | 4 +- .../lj-1047-fix-funccw-arm64.test.c | 105 ++++++++++++++++++ 2 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 test/tarantool-c-tests/lj-1047-fix-funccw-arm64.test.c
It is not clear why the test (or patch) is arm64-specific.
Either explain in the commit message or remove suffix.
<snipped>