<!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>Hi, Sergey,</p>
    <p>thanks for the patch! LGTM<br>
    </p>
    <div class="moz-cite-prefix">On 11.09.2024 10:04, Sergey Kaplun
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20240911070405.28163-1-skaplun@tarantool.org">
      <pre class="moz-quote-pre" wrap="">From: Mike Pall <mike>

Suggested by Hydroque.

(cherry picked from commit 03cd5aa749c1bc3bb4b7d4289236b6096cb3dc85)

This patch makes the Lua stack balanced after using the aforementioned
function, which is considered a good practice [1]. Be aware that the
only argument on the stack is dummy NULL from the `lua_cpcall()`, so it
can be easily cleared. This doesn't change the behaviour since all calls
of `print_jit_status()` are followed by `dotty()` with a call to
`loadline()`, which clears the stack anyway.

Sergey Kaplun:
* added the description for the patch

[1]: <a class="moz-txt-link-freetext" href="https://www.lua.org/manual/5.1/manual.html#lua_call">https://www.lua.org/manual/5.1/manual.html#lua_call</a>

Part of tarantool/tarantool#10199
---

Branch: <a class="moz-txt-link-freetext" href="https://github.com/tarantool/luajit/tree/skaplun/lj-382-clear-stack-after-jit-status">https://github.com/tarantool/luajit/tree/skaplun/lj-382-clear-stack-after-jit-status</a>
Issue: <a class="moz-txt-link-freetext" href="https://github.com/tarantool/tarantool/issues/10199">https://github.com/tarantool/tarantool/issues/10199</a>

 src/luajit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/luajit.c b/src/luajit.c
index b63c92d1..e04a5a30 100644
--- a/src/luajit.c
+++ b/src/luajit.c
@@ -162,6 +162,7 @@ static void print_jit_status(lua_State *L)
     fputs(s, stdout);
   }
   putc('\n', stdout);
+  lua_settop(L, 0);  /* clear stack */
 }
 
 static void createargtable(lua_State *L, char **argv, int argc, int argf)
</pre>
    </blockquote>
  </body>
  <lt-container></lt-container>
</html>