From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 551E8D71949; Thu, 12 Sep 2024 14:49:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 551E8D71949 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1726141774; bh=KR6BdqQ6YHKM6BvJInDZdXwj3mzuiMPceDv/ZJwnkbw=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=kCdLHnPRu0scXHgRRYwUIlYOVpRGmNrsL6VXoSo7PC6NA+gs5J3m4HV/vn8uFS3fU epMNZBUhMQ36fAlbXpzsfHApOHVxem+u2/GAH66BJiqmiSLIg6K/0BEoMyt+RtAvds p0oGwy2K2BZXw/oHkDbnAR74LikhLm+s/A/1DCNI= Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [95.163.41.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id CF847D71949 for ; Thu, 12 Sep 2024 14:49:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CF847D71949 Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1soiKK-0000000FSNl-2voa; Thu, 12 Sep 2024 14:49:33 +0300 Content-Type: multipart/alternative; boundary="------------qlb39PqCWlHIE5k9YPR0Ows0" Message-ID: <89770c16-48ad-40e6-a4b5-ff0b111c3b55@tarantool.org> Date: Thu, 12 Sep 2024 14:49:32 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <20240911070405.28163-1-skaplun@tarantool.org> In-Reply-To: <20240911070405.28163-1-skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91486559A3ABF84E7AA02C4391ACD38D4D1E92FCEE46C1725182A05F53808504049FD34F87F9D993A411046492FDDF806C0ABDE1519C96DDDFD4737C3657A425A173EA8EFF67FC3C9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77603ADE015AF816DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C218CA8E848E3B7A8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CF5B202CFB9843EFF4D16DB46F5FE5C04556FB1F01DB3B11CC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F79006372A3B24BF85B2E607389733CBF5DBD5E9B5C8C57E37DE458BD9DD9810294C998ED8FC6C240DEA76428AA50765F7900637332B1D7AE5E7D98AD81D268191BDAD3DBD4B6F7A4D31EC0BE2F48590F00D11D6D81D268191BDAD3D78DA827A17800CE7BC8BFE2E4A327A7BEC76A7562686271ED91E3A1F190DE8FD2E808ACE2090B5E14AD6D5ED66289B5259CC434672EE63711DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3F6A27782D052760535872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A55D7E5D94214600925002B1117B3ED69631D8FE38379F2A03250A03108B67251B823CB91A9FED034534781492E4B8EEADC3194D76C41E9723BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF05D4D9CECA3E07132DC5EF22465535BE4D95C79FCC116677815ADDBA2D379375F02FE508BB13AAFBBA3E0C39EEA44CB3D3A05525DE4FE37BE581C0D0D2B57166548875048ABDB73D5F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojBIBNH8BG++fmenRtyI0+Cw== X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F2588458C84AA4C1207E4207FD3DE253F98C97F8A5C6223CAB94F535C7C9C90A22AE45FF645D15D82EE4B272BD6E4642A116CA93524AA66B5ACBE6721EF430B9A63E2A504198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Clear stack after print_jit_status() in CLI. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------qlb39PqCWlHIE5k9YPR0Ows0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey, thanks for the patch! LGTM On 11.09.2024 10:04, Sergey Kaplun wrote: > From: Mike Pall > > 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) --------------qlb39PqCWlHIE5k9YPR0Ows0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey,

thanks for the patch! LGTM

On 11.09.2024 10:04, Sergey Kaplun wrote:
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)
--------------qlb39PqCWlHIE5k9YPR0Ows0--