From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Bronnikov <sergeyb@tarantool.org>
Cc: Sergey Bronnikov <estetus@gmail.com>,
tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] LJ_FR2: Fix stack checks in vararg calls.
Date: Mon, 27 Oct 2025 11:16:25 +0300 [thread overview]
Message-ID: <aP8qWSAbrPi3gHTf@root> (raw)
In-Reply-To: <b6347e71-2222-4fde-8d39-4531ea88e8f2@tarantool.org>
Hi, Sergey!
Thanks for the fixes!
Please consider my comments below.
Also, please send the next version via v2 series to simplify the
review.
On 23.09.25, Sergey Bronnikov wrote:
> Hi, Sergey,
>
> thanks for review! Please see my comments below.
>
> Sergey
>
> On 9/1/25 16:07, Sergey Kaplun via Tarantool-patches wrote:
> > Hi, Sergey!
> > Thanks for the patch!
> > Please consider my comments below.
> >
> > On 27.08.25, Sergey Bronnikov wrote:
<snipped>
> >> Sergey Bronnikov:
> >> * added the description and the test for the problem
> >>
> >> Part of tarantool/tarantool#11691
> >> ---
> >> src/lj_def.h | 2 +-
> >> src/lj_dispatch.c | 2 +-
> >> src/vm_arm64.dasc | 1 +
> >> src/vm_mips64.dasc | 1 +
> >> ...048-fix-stack-checks-vararg-calls.test.lua | 56 +++++++++++++++++++
> >> 5 files changed, 60 insertions(+), 2 deletions(-)
> >> create mode 100644 test/tarantool-tests/lj-1048-fix-stack-checks-vararg-calls.test.lua
> >>
> >> diff --git a/src/lj_def.h b/src/lj_def.h
> > <snipped>
> >
> >> diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c
> >> index a44a5adf..431cb3c2 100644
> >> --- a/src/lj_dispatch.c
> >> +++ b/src/lj_dispatch.c
> >> @@ -453,7 +453,7 @@ static int call_init(lua_State *L, GCfunc *fn)
> >> int numparams = pt->numparams;
> >> int gotparams = (int)(L->top - L->base);
> >> int need = pt->framesize;
> >> - if ((pt->flags & PROTO_VARARG)) need += 1+gotparams;
> >> + if ((pt->flags & PROTO_VARARG)) need += 1+LJ_FR2+gotparams;
> > I can't see the test related to this change. Not `prober_1()` nor
> > `prober_2()` lead to the assertion failure for x86_64 or aarch64 without
> > it.
>
> Please check again. Both testcases trigger segfault on AArch64 (odroid).
Double checked:
| root@odroid:/home/skaplun/lj-1048-review# git diff
| diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c
| index 431cb3c2..a44a5adf 100644
| --- a/src/lj_dispatch.c
| +++ b/src/lj_dispatch.c
| @@ -453,7 +453,7 @@ static int call_init(lua_State *L, GCfunc *fn)
| int numparams = pt->numparams;
| int gotparams = (int)(L->top - L->base);
| int need = pt->framesize;
| - if ((pt->flags & PROTO_VARARG)) need += 1+LJ_FR2+gotparams;
| + if ((pt->flags & PROTO_VARARG)) need += 1+gotparams;
| lj_state_checkstack(L, (MSize)need);
| numparams -= gotparams;
| return numparams >= 0 ? numparams : 0;
| Test project /home/skaplun/lj-1048-review
| Start 118: test/tarantool-tests/lj-1048-fix-stack-checks-vararg-calls.test.lua
| 1/1 Test #118: test/tarantool-tests/lj-1048-fix-stack-checks-vararg-calls.test.lua ... Passed 3.38 sec
|
| 100% tests passed, 0 tests failed out of 1
|
| Label Time Summary:
| tarantool-tests = 3.38 sec*proc (1 test)
|
| Total Test time (real) = 3.42 sec
<snipped>
> >> +-- patch.
> >> +local function prober_1(...) -- luacheck: no unused
> >> + pcall(pcall, pcall, pcall, pcall, pcall, pcall, pcall, pcall, pairs, {})
> >> +end
> > Why do we want to use probber_1 here? Why is this different from the
> > second example? Only because of the metamethods?
Still need an explanation.
> >
> > If we want to keep it, please describe why we need at least 9 pcall-s.
> As I got right, exactly this number of pcall's is needed to trigger a
> stack overflow.
Yes, but why 9 is minimum number of pcall's when the issue is reproduced?
<snipped>
--
Best regards,
Sergey Kaplun
next prev parent reply other threads:[~2025-10-27 8:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 9:44 [Tarantool-patches] [PATCH luajit 0/2] Fix stack overflow in pcall/xpcall Sergey Bronnikov via Tarantool-patches
2025-08-27 9:44 ` [Tarantool-patches] [PATCH luajit 1/2] LJ_FR2: Fix stack checks in vararg calls Sergey Bronnikov via Tarantool-patches
2025-09-01 13:07 ` Sergey Kaplun via Tarantool-patches
2025-09-23 17:49 ` Sergey Bronnikov via Tarantool-patches
2025-10-27 8:16 ` Sergey Kaplun via Tarantool-patches [this message]
2025-08-27 9:44 ` [Tarantool-patches] [PATCH luajit 2/2] Add stack check to pcall/xpcall Sergey Bronnikov via Tarantool-patches
2025-09-01 13:36 ` Sergey Kaplun via Tarantool-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aP8qWSAbrPi3gHTf@root \
--to=tarantool-patches@dev.tarantool.org \
--cc=estetus@gmail.com \
--cc=sergeyb@tarantool.org \
--cc=skaplun@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH luajit 1/2] LJ_FR2: Fix stack checks in vararg calls.' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox