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 A4EB3C24348; Mon, 22 Apr 2024 11:56:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A4EB3C24348 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1713776200; bh=pB0qQNh5qKp3314J+lzuRiUvkQo5uRWFCKJTZI53Pm4=; 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=DuUo9RXVwZUHhVXqWeSTg2K/roLe9B0gr1csOmyS0GdPOK8GHwPH2CuQlRwd1lLFf 1YI77WcY/nx6nX+47h+GVQLqWhiDBtRbW9wHdXLksBBX6FpM8ww0SqY2B6bIMFETit 2DnBrMZnjuJ3rieQ+YmnAj5wPlKEBsJF6bl1PRkU= Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [95.163.41.73]) (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 47616BB133B for ; Mon, 22 Apr 2024 11:54:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 47616BB133B Received: by smtp32.i.mail.ru with esmtpa (envelope-from ) id 1rypRE-0000000BtKy-240A; Mon, 22 Apr 2024 11:54:12 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Mon, 22 Apr 2024 11:49:58 +0300 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD981EF5929CFC9C984D61AA524D466E1F828869B48C349CC5D00894C459B0CD1B9640F5201E3C60B7FAD29F1F059031B349EEC1FF1D3E1830C959CEBAA5A3E512F74CA12CB93F4C0D9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7E2331B2371EFE129EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375AFA801FF88E3EFD8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8868592DE767CFF131DBF48A0D5DCDA27B621175D6927B5ECCC7F00164DA146DAFE8445B8C89999728AA50765F7900637D9CFB327BC390E24389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8724336BCC0EE1BA8F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C3820445CF21F0C3C040F9FF01DFDA4A84AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3ED2B9A73A0246C5BBA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF17B107DEF921CE791DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3CE9959E2676FD87735872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A54741598A895A2B6A5002B1117B3ED696F445A21CD419506EB48B7A7F94616420823CB91A9FED034534781492E4B8EEAD4ADCFBF7921B375DC79554A2A72441328621D336A7BC284946AD531847A6065A17B107DEF921CE79BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF7E6864FDAEC2B1CDA767B2B00344A08F259829F9BB2C237B9FA26E67C6F66D9DF93E7F6CC6F26229A1583B225F58ABB2DBAEBAE25BBC6D78743E605242C55F8DD3AEB6EEDB22A6CCC226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojerYCxSdLZTaueEu6DHrWrw== X-Mailru-Sender: 520A125C2F17F0B1A9638AD358559B59D067DC19FB5A723433594132A326AF8B6CE03BB256F0E50EB7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit v1 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 | 41 ++++++++++++++++++- ...j-1166-error-stitch-oom-snap-buff.test.lua | 37 +++++++++++++++-- 3 files changed, 75 insertions(+), 5 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 e3a5397d..cf3ab0f5 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-snap-buff'):skipcond({ ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', }) -test:plan(1) - +local jparse = require('utils').jit.parse local mockalloc = require('mockalloc') +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) + local function create_chunk(n_slots) local chunk = '' for i = 1, n_slots do @@ -33,6 +41,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') mockalloc.mock() @@ -41,6 +53,31 @@ tracef() mockalloc.unmock() +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({ + -- luacheck: no global + ['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 8d671f8d..8bbdd96b 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 mockalloc = require('mockalloc') +-- XXX: Avoid other traces compilation due to hotcount collisions +-- for predictable results. +jit.off() +jit.flush() + +test:plan(2) + local function create_chunk(n_conds) local chunk = '' chunk = chunk .. 'for i = 1, 2 do\n' @@ -27,6 +33,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') @@ -38,9 +45,11 @@ 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() mockalloc.mock() @@ -49,6 +58,28 @@ tracef() mockalloc.unmock() +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({ + -- luacheck: no global + ['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.44.0