Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH luajit] Clear stack after print_jit_status() in CLI.
@ 2024-09-11  7:04 Sergey Kaplun via Tarantool-patches
  2024-09-12 11:49 ` Sergey Bronnikov via Tarantool-patches
  2024-09-19  9:20 ` Maxim Kokryashkin via Tarantool-patches
  0 siblings, 2 replies; 3+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-09-11  7:04 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

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]: https://www.lua.org/manual/5.1/manual.html#lua_call

Part of tarantool/tarantool#10199
---

Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-382-clear-stack-after-jit-status
Issue: https://github.com/tarantool/tarantool/issues/10199

 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)
-- 
2.46.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-19  9:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-11  7:04 [Tarantool-patches] [PATCH luajit] Clear stack after print_jit_status() in CLI Sergey Kaplun via Tarantool-patches
2024-09-12 11:49 ` Sergey Bronnikov via Tarantool-patches
2024-09-19  9:20 ` Maxim Kokryashkin via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox