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 D6415ED5919; Thu, 6 Jun 2024 17:06:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D6415ED5919 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1717682813; bh=NACViUbxvcTWxwIjKV1ZscjLXliZZvfEI7kkZ81YsjU=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dflIZmfx6jpfhfnXAta5g7cjqxzT0ZdesbmKUte3aZNLHDLNzJ76jFKY3aSnAk+7m Cs9b8PDwNAWBr8xeJbyJNjSvZdOOADyOOYbfrQrvtFJ3Q+pTe6EfJB82ChtZSxcmm3 teOsCn6yiZtccyznGIhTxFocuAN/wQMzMW67agKc= Received: from smtp30.i.mail.ru (smtp30.i.mail.ru [95.163.41.71]) (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 D1F14ED5919 for ; Thu, 6 Jun 2024 17:06:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D1F14ED5919 Received: by smtp30.i.mail.ru with esmtpa (envelope-from ) id 1sFDlT-0000000H2Ip-2r1K; Thu, 06 Jun 2024 17:06:52 +0300 Content-Type: multipart/alternative; boundary="------------qRfN8TsH0J0W6u2rpeAgf0Xb" Message-ID: Date: Thu, 6 Jun 2024 17:06:51 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD948651DF6EBC8E8B222621CCF380C0F235C86A77A6A247FFB182A05F538085040ADDC4B232618A84489CEA9C911D0999559177E039F657390C3D674CB47364ACC87C9673BEE2CBA79 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77D3344F2D0C9F5BEEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063761B0653E4D5FA7998638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8EEB9AC22DEEA9AA6EFD4364875DA3516AEE21DEDFD9599EDCC7F00164DA146DAFE8445B8C89999728AA50765F79006370277CA7F994D7EF5389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8ED96AA85C75E140D117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CF663A3A66E4CB0153BA3038C0950A5D36C8A9BA7A39EFB766D91E3A1F190DE8FDBA3038C0950A5D36D5E8D9A59859A8B6C034E9EF55F0086276E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C0BF7CEC3D2FC0D9C43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5FC78EB030F5026265002B1117B3ED6963B516117E7FF5209AD0703CEB2EF9A27823CB91A9FED034534781492E4B8EEADA2D5570B22232E1EBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF743925186AE3850C3A4C6E0391DD1CAE851738B75087977A53BDC01A15D6B52D5B8C288B04B80C1C00094467C1BF539CE4E5DA27CCFA86291D9A82BF3D4CA14346A6954D3BC30A385F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj3qkQfioj9XTh2aQcX2D0uA== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D61409B0AF4E859122BF04B57D4374BFB99D67CF5B0718DFD10BF0152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------qRfN8TsH0J0W6u2rpeAgf0Xb Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sergey, thanks for the patch! See my comments below. Sergey On 22.04.2024 11:49, Sergey Kaplun wrote: > 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 I made a patch that remove inline suppressions [1]. I propose to merge it and remove inline suppressions in your patch series too. [1]: https://lists.tarantool.org/tarantool-patches/88eab16fca9056a057df5506a0af637c8d4a0ffd.1717682341.git.sergeyb@tarantool.org/T/#u > + ['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') Same comment as in previous mail - let's add a comment regarding 't'. > + > -- XXX: Update hotcounts to avoid hash collisions. > jit.opt.start('hotloop=1') > - > jit.on() > > mockalloc.mock() > @@ -49,6 +58,28 @@ tracef() > > mockalloc.unmock() Same comment as in previous mail - let's avoid name 'mock' here. > > +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) --------------qRfN8TsH0J0W6u2rpeAgf0Xb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Sergey,


thanks for the patch! See my comments below.


Sergey

On 22.04.2024 11:49, Sergey Kaplun wrote:
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 | 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

I made a patch that remove inline suppressions [1].

I propose to merge it and remove inline suppressions in your patch series too.


[1]: https://lists.tarantool.org/tarantool-patches/88eab16fca9056a057df5506a0af637c8d4a0ffd.1717682341.git.sergeyb@tarantool.org/T/#u

+  ['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')
Same comment as in previous mail - let's add a comment regarding 't'.
+
 -- XXX: Update hotcounts to avoid hash collisions.
 jit.opt.start('hotloop=1')
-
 jit.on()
 
 mockalloc.mock()
@@ -49,6 +58,28 @@ tracef()
 
 mockalloc.unmock()
Same comment as in previous mail - let's avoid name 'mock' here.
 
+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)
--------------qRfN8TsH0J0W6u2rpeAgf0Xb--