From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Maxim Kokryashkin <m.kokryashkin@tarantool.org>, Sergey Bronnikov <sergeyb@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH v2 luajit 5/5] Use generic trace error for OOM during trace stitching. Date: Sun, 16 Jun 2024 13:00:13 +0300 [thread overview] Message-ID: <6a52fe6b60b4cb98c9e94ac8b7e204e35cb4da15.1718528874.git.skaplun@tarantool.org> (raw) In-Reply-To: <cover.1718528874.git.skaplun@tarantool.org> From: Mike Pall <mike> Thanks to Sergey Kaplun. (cherry picked from commit b8b49bf3954b23e32e34187a6ada00021c26e172) The previous commit doesn't handle the case when the error code is `LUA_ERRMEM`. This patch adds a workaround by using the generic error message. Sergey Kaplun: * added the description and the test for the problem Part of tarantool/tarantool#9924 --- src/lj_ffrecord.c | 2 + .../lj-1166-error-stitch-oom-ir-buff.test.lua | 40 ++++++++++++++++++- ...j-1166-error-stitch-oom-snap-buff.test.lua | 35 +++++++++++++++- 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c index ff14e9e4..d5fc081e 100644 --- a/src/lj_ffrecord.c +++ b/src/lj_ffrecord.c @@ -150,6 +150,8 @@ static void recff_stitch(jit_State *J) if (errcode) { if (errcode == LUA_ERRRUN) copyTV(L, L->top-1, L->top + (1 + LJ_FR2)); + else + setintV(L->top-1, (int32_t)LJ_TRERR_RECERR); lj_err_throw(L, errcode); /* Propagate errors. */ } } diff --git a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua index 85afea11..354f5975 100644 --- a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua +++ b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua @@ -10,10 +10,18 @@ local test = tap.test('lj-1166-error-stitch-oom-ir-buff'):skipcond({ ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', }) -test:plan(1) - +local jparse = require('utils').jit.parse local allocinject = require('allocinject') +local IS_DUALNUM = tostring(tonumber('-0')) ~= tostring(-0) + +-- XXX: Avoid other traces compilation due to hotcount collisions +-- for predictable results. +jit.off() +jit.flush() + +test:plan(2) + -- Generate the following Lua chunk: -- local s1 -- ... @@ -43,6 +51,10 @@ end -- XXX: amount of slots is empirical. local tracef = assert(loadstring(create_chunk(175))) +-- We only need the abort reason in the test. +jparse.start('t') + +jit.on() jit.opt.start('hotloop=1', '-loop', '-fold') allocinject.enable() @@ -51,6 +63,30 @@ tracef() allocinject.disable() +local _, aborted_traces = jparse.finish() + +jit.off() + test:ok(true, 'stack is balanced') +-- Tarantool may compile traces on the startup. These traces +-- already exceed the maximum IR amount before the trace in this +-- test is compiled. Hence, there is no need to reallocate the IR +-- buffer, so the check for the IR size is not triggered. +test:skipcond({ + ['Impossible to predict the number of IRs for Tarantool'] = _TARANTOOL, + -- The amount of IR for traces is different for non x86/x64 + -- arches and DUALNUM mode. + ['Disabled for non-x86_64 arches'] = jit.arch ~= 'x64' and jit.arch ~= 'x86', + ['Disabled for DUALNUM mode'] = IS_DUALNUM, +}) + +assert(aborted_traces and aborted_traces[1], 'aborted trace is persisted') + +-- We tried to compile only one trace. +local reason = aborted_traces[1][1].abort_reason + +test:like(reason, 'error thrown or hook called during recording', + 'abort reason is correct') + test:done(true) diff --git a/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua b/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua index ea50ebc4..c8e13760 100644 --- a/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua +++ b/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua @@ -10,10 +10,16 @@ local test = tap.test('lj-1166-error-stitch-oom-snap-buff'):skipcond({ ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', }) -test:plan(1) - +local jparse = require('utils').jit.parse local allocinject = require('allocinject') +-- XXX: Avoid other traces compilation due to hotcount collisions +-- for predictable results. +jit.off() +jit.flush() + +test:plan(2) + -- Generate the following Lua chunk: -- for i = 1, 2 do -- if i < 1 then end @@ -34,6 +40,7 @@ local function create_chunk(n_conds) return chunk end +jit.on() -- XXX: Need to compile the cycle in the `create_chunk()` to -- preallocate the snapshot buffer. jit.opt.start('hotloop=1', '-loop', '-fold') @@ -45,6 +52,9 @@ local tracef = assert(loadstring(create_chunk(6))) jit.off() jit.flush() +-- We only need the abort reason in the test. +jparse.start('t') + -- XXX: Update hotcounts to avoid hash collisions. jit.opt.start('hotloop=1') jit.on() @@ -55,6 +65,27 @@ tracef() allocinject.disable() +local _, aborted_traces = jparse.finish() + +jit.off() + test:ok(true, 'stack is balanced') +-- Tarantool may compile traces on the startup. These traces +-- already exceed the maximum snapshot amount before the trace in +-- this test is compiled. Hence, there is no need to reallocate +-- the snapshot buffer, so the check for the snap size is not +-- triggered. +test:skipcond({ + ['Impossible to predict the number of snapshots for Tarantool'] = _TARANTOOL, +}) + +assert(aborted_traces and aborted_traces[1], 'aborted trace is persisted') + +-- We tried to compile only one trace. +local reason = aborted_traces[1][1].abort_reason + +test:like(reason, 'error thrown or hook called during recording', + 'abort reason is correct') + test:done(true) -- 2.45.1
next prev parent reply other threads:[~2024-06-16 10:07 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-06-16 10:01 [Tarantool-patches] [PATCH v2 luajit 0/5] Handle all errors during stitching Sergey Kaplun via Tarantool-patches 2024-06-16 10:00 ` [Tarantool-patches] [PATCH v2 luajit 1/5] build: introduce option LUAJIT_ENABLE_TABLE_BUMP Sergey Kaplun via Tarantool-patches 2024-06-16 10:00 ` [Tarantool-patches] [PATCH v2 luajit 2/5] ci: add tablebump flavor for exotic builds Sergey Kaplun via Tarantool-patches 2024-06-16 10:00 ` [Tarantool-patches] [PATCH v2 luajit 3/5] test: allow `jit.parse` to return aborted traces Sergey Kaplun via Tarantool-patches 2024-06-16 10:00 ` [Tarantool-patches] [PATCH v2 luajit 4/5] Handle all types of errors during trace stitching Sergey Kaplun via Tarantool-patches 2024-06-16 10:00 ` Sergey Kaplun via Tarantool-patches [this message] 2024-06-18 8:40 ` [Tarantool-patches] [PATCH v2 luajit 0/5] Handle all errors during stitching Sergey Bronnikov via Tarantool-patches 2024-07-09 8:04 ` 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=6a52fe6b60b4cb98c9e94ac8b7e204e35cb4da15.1718528874.git.skaplun@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=m.kokryashkin@tarantool.org \ --cc=sergeyb@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 luajit 5/5] Use generic trace error for OOM during trace stitching.' \ /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