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 4C565C6B3A9; Sun, 16 Jun 2024 13:07:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4C565C6B3A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1718532422; bh=itMlA2USoXk7CWEqRF+VovnZY5VQRS2PmT/sHuu1slc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=FM7fjdCx+K9xsdYuxwFCSl6YOlZjOTrLrqGrT6QFYptQMeUqbUSHGGfriXDdfIs4Q KsB18S4+cz77Q5wq6Mrxd2d5OA7/wHErqGIA2lsug5XCSFuNc0isBEQYMAiO0zGXIb 6EBw3QQoR+cKnQOYbt77Qxs1XfwFG/IxGQ8MVRNg= Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [95.163.41.80]) (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 14639C6B397 for ; Sun, 16 Jun 2024 13:04:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 14639C6B397 Received: by smtp39.i.mail.ru with esmtpa (envelope-from ) id 1sImkS-0000000Fftq-3rJb; Sun, 16 Jun 2024 13:04:33 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Sun, 16 Jun 2024 13:00:13 +0300 Message-ID: <6a52fe6b60b4cb98c9e94ac8b7e204e35cb4da15.1718528874.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9AC8CA0B4439200FAAB3485384346218550C915DCECBB078D00894C459B0CD1B908D7A05399A2506210B999B7BE3335B5A68EB15AD76F1CB9DF8292320A6A54192D5CFE12AD13DA04 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE797F4D2EDC29AFAF7EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637380C9B139A8DC37F8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8E989511304D2CE42AE6BF3E8E72F99D9CC16E5B724E3A0C4CC7F00164DA146DAFE8445B8C89999728AA50765F790063767B9C6E70FBE8DD8389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8BC0ADEB1C81BB362F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F7900637F09814068C508CC822CA9DD8327EE4930A3850AC1BE2E7356C9A9530EBF72002C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5915F378AC685AB175002B1117B3ED6968F6174A7BE81A8E8361FAC1196A180DE823CB91A9FED034534781492E4B8EEAD9F68E8F4EDE74A9DC79554A2A72441328621D336A7BC284946AD531847A6065A17B107DEF921CE79BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF5B0D9CB39D83CC2C0FC895ABD09ADE5376B9CEA0B45B08B8706C7FED9AD0CDA7E80DAFFC47B24EFFBC11D93875BCBCAC4EC6393BF3CC595F992F8167577D1E7C01176E1BE3B2A82AC226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojsYa7y8j7e8dbA9kR1G0fZA== X-DA7885C5: E57C5C3764B79057F255D290C0D534F9D4421CA0AC0AAEFD2864DCB410310284A274407769B988225B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393C6D0B12EA33CAA9BC799C7C1563D1839294DC2D8F921DC3473EF145D5DCD4492E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 5/5] Use generic trace error for OOM during trace stitching. 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 Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Mike Pall 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