From: Maxim Kokryashkin via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Kaplun <skaplun@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH luajit] Check frame size limit before returning to a lower frame. Date: Tue, 12 Mar 2024 15:21:15 +0300 [thread overview] Message-ID: <wohyip34besqfm66pml6vavi6w4ef4rpzwulmzvmp4b7lk4cd7@nnmb34vhorkg> (raw) In-Reply-To: <20240312052627.21222-1-skaplun@tarantool.org> Hi, Sergey! Thanks for the patch! LGTM, except for the single comment below. On Tue, Mar 12, 2024 at 08:26:27AM +0300, Sergey Kaplun wrote: > From: Mike Pall <mike> > > Thanks to Sergey Kaplun. > > (cherry picked from commit 302366a33853b730f1b7eb61d792abc4f84f0caa) > > When compiling a stitched (or side) trace, there is no check for the > frame size of the current prototype during recording. Hence, when we > return (for example, after stitching) to the lower frame with a maximum > possible frame size (249), the 251 = `baseslot` (2) + `maxslot` (249) > slot for GC64 mode may be used. This leads to the corresponding assertion > failure in `rec_check_slots()`. > > This patch adds the corresponding check. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#9595 > --- > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1173-frame-limit-lower-frame > Tarantool PR: https://github.com/tarantool/tarantool/pull/9791 > Related issues: > * https://github.com/tarantool/tarantool/issues/9595 > * https://github.com/LuaJIT/LuaJIT/issues/1173 > > src/lj_record.c | 2 + > .../lj-1173-frame-limit-lower-frame.test.lua | 83 +++++++++++++++++++ > 2 files changed, 85 insertions(+) > create mode 100644 test/tarantool-tests/lj-1173-frame-limit-lower-frame.test.lua > > diff --git a/src/lj_record.c b/src/lj_record.c > index c01c1f0b..e3590b1a 100644 > --- a/src/lj_record.c > +++ b/src/lj_record.c <snipped> > diff --git a/test/tarantool-tests/lj-1173-frame-limit-lower-frame.test.lua b/test/tarantool-tests/lj-1173-frame-limit-lower-frame.test.lua > new file mode 100644 > index 00000000..91e2c603 > --- /dev/null > +++ b/test/tarantool-tests/lj-1173-frame-limit-lower-frame.test.lua > @@ -0,0 +1,83 @@ <snipped> > +local chunk = 'local uv = {key = 1}\n' > +chunk = chunk .. 'return function()\n' > +chunk = chunk .. 'local r = retf()\n' Kind of a strange way to define a chunk. I believe that multiline is better here. > + > +-- Each `UGET` occupies 1 slot, `KNIL` occupies the same amount. > +-- 1 slot is reserved (`r` variable), 1 pair is set outside the > +-- cycle. 249 slots (the maximum available amount, see > +-- <src/lj_parse.c>, `bcreg_bump()` for details) are occupied in > +-- total. > +for _ = 1, LJ_MAX_JSLOTS / 2 - 2 do > + chunk = chunk .. ('uv.key, ') > +end > +chunk = chunk .. 'uv.key = nil\n' > +chunk = chunk .. 'end\n' Same applies here. > + > +local get_func = assert(loadstring(chunk)) > +local function_max_framesize = get_func() > + > +jit.opt.start('hotloop=1', 'hotexit=1') > + > +-- Compile the parent trace first. > +retf() > +retf() > + > +-- Try to compile the side trace with a return to a lower frame > +-- with a huge frame size. > +function_max_framesize() > +function_max_framesize() > + > +-- XXX: The limit check is OK with default defines for non-GC64 > +-- mode, the trace is compiled for it. The test fails only with > +-- GC64 mode enabled. Still run the test for non-GC64 mode to > +-- avoid regressions. > + > +test:ok(true, 'no assertion failure during recording') > + > +test:done(true) > -- > 2.44.0 >
next prev parent reply other threads:[~2024-03-12 12:21 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-12 5:26 Sergey Kaplun via Tarantool-patches 2024-03-12 8:01 ` Sergey Bronnikov via Tarantool-patches 2024-03-13 9:37 ` Sergey Kaplun via Tarantool-patches 2024-03-13 11:33 ` Sergey Bronnikov via Tarantool-patches 2024-03-13 12:35 ` Sergey Kaplun via Tarantool-patches 2024-03-13 13:03 ` Sergey Bronnikov via Tarantool-patches 2024-03-12 12:21 ` Maxim Kokryashkin via Tarantool-patches [this message] 2024-03-13 8:35 ` Sergey Kaplun via Tarantool-patches 2024-03-13 8:50 ` Maxim Kokryashkin via Tarantool-patches 2024-03-20 15:07 ` 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=wohyip34besqfm66pml6vavi6w4ef4rpzwulmzvmp4b7lk4cd7@nnmb34vhorkg \ --to=tarantool-patches@dev.tarantool.org \ --cc=m.kokryashkin@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit] Check frame size limit before returning to a lower frame.' \ /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