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 2F56458162A; Fri, 13 Mar 2026 13:06:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2F56458162A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1773396397; bh=zZAnwBmEd3FhSAut2tsp5WqAYBgRQBSvJCP9P//K7ho=; 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=WjTY7SpdjJ8JGe16pDk/a0oTVJEMIlcvY3VtJvn+OSAT8yLJwlaHwNCNXBUHQJbAn TB+XoYPQYQE/39+HNJjoxONFfqFAjLcgTlNPNrr8tR4FL1poFZaUXqDHsWTRoJNz3n p1RwFdrhTL/ii1cTLL0BUZEUrgnytbqxhPyZavY0= Received: from send278.i.mail.ru (send278.i.mail.ru [95.163.59.117]) (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 2B34358162A for ; Fri, 13 Mar 2026 13:06:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2B34358162A Received: by exim-smtp-64cdfc6c8d-lz2n2 with esmtpa (envelope-from ) id 1w0zPf-00000000LpT-0WD6; Fri, 13 Mar 2026 13:06:35 +0300 Date: Fri, 13 Mar 2026 13:07:30 +0300 To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Message-ID: References: <334e8dd174e6f4c9a03b3a5827c36d5353a85238.1773330679.git.skaplun@tarantool.org> <4454d7e1-43a6-4151-b39f-26fec9a7f04d@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4454d7e1-43a6-4151-b39f-26fec9a7f04d@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91ABAE9865AC7DC8818B4CD52367FE98173B6651699D6E8DA182A05F53808504098639D73607590053DE06ABAFEAF6705EDE8D64C4AD07E32B53C1B879887BB0243EB7D3813763A1D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C4A7E4C0BFE8628DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB5533756627194F95AE6E7C2D872B0E234335CCB40715B600F97FD3B4ED843742C032BED4389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0A29E2F051442AF778941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B636DA1BED736F9328CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C22493271950E746CB25C76E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8BEE6865575290A7923AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735D2D576BCF940C736C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A58B5E5536357160A05002B1117B3ED696C91B5E5194D356FA7E0012C66AE17B00823CB91A9FED034534781492E4B8EEADAE4FDBF11360AC9BBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6597A4FD9E7741B86BC67C0BB0850999BFC859B80580A2AD7F6364BC7F0D5BA2CAE151067DFD57641D7B8341EE9D5BE9A0A37A7B34EDF8DCE27C78025589DA6D29F448C3C9980A7C8CB8CD93680B12512CF4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdbVVJCphTR/JkmmKrqMuUk= X-Mailru-Sender: 583F1D7ACE8F49BDD951BA70C165859E8D82EDAA526FB0079B464708D7791FD7148A4ABB7644DFBDCA051C13401809B8F2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A84198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] Prevent recording of loops with -0 step or NaN values. 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the review! Fixed your comments and updated the branch. On 13.03.26, Sergey Bronnikov wrote: > Hi, Sergey, > > thanks for the patch! LGTM with minor comments. > > Sergey > > On 3/12/26 18:55, Sergey Kaplun wrote: > > From: Mike Pall > > > > Thanks to Sergey Kaplun. > > > > (cherry picked from commit 54cce2e1719a15fc33e40c57dbc3d62e9c104b03) > > > > The -0 step and NaN control variable values may lead to the traces > > with always failed guards. > > > > This patch forbids recording of such traces since these traces are not > > very useful. Unfortunately, this breaks for loop recording in DUALNUM > > mode. This will be fixed in the next commit. > > > > Sergey Kaplun: > > * added the description and the test for the problem > > > > Part of tarantool/tarantool#12134 > > --- > > src/lj_record.c | 6 ++ > > .../lj-1432-minus-zero-step.test.lua | 57 +++++++++++++ > > .../lj-1433-nan-for-control-var.test.lua | 79 +++++++++++++++++++ > > 3 files changed, 142 insertions(+) > > create mode 100644 test/tarantool-tests/lj-1432-minus-zero-step.test.lua > > create mode 100644 test/tarantool-tests/lj-1433-nan-for-control-var.test.lua > > > > diff --git a/src/lj_record.c b/src/lj_record.c > > index 81da43f5..a3a68b57 100644 > > --- a/src/lj_record.c > > +++ b/src/lj_record.c > > diff --git a/test/tarantool-tests/lj-1432-minus-zero-step.test.lua b/test/tarantool-tests/lj-1432-minus-zero-step.test.lua > > new file mode 100644 > > index 00000000..112153dc > > --- /dev/null > > +++ b/test/tarantool-tests/lj-1432-minus-zero-step.test.lua > > @@ -0,0 +1,57 @@ > > +local tap = require('tap') > > + > > +-- Test file to check the correct recording of -0 step for value. > > +-- See alsohttps://github.com/LuaJIT/LuaJIT/issues/1432. > > + > > +local test = tap.test('lj-1432-minus-zero-step'):skipcond({ > > + ['Test requires JIT enabled'] = not jit.status(), > > +}) > > + > > +test:plan(2) > > + > > +local traceinfo = require('jit.util').traceinfo > > + > > +local function trace_slot() > > + local counter = 0 > > + local slot = -0 > > + -- Run the inner trace several times. Before the patch, it leads > > + -- to several child traces due to the always failed guards. > > + while true do > > + if counter > 5 then break end > > + counter = counter + 1; > > + -- luacheck: ignore > > + for _ = 1, 1, slot do > > + break > > + end > > + end > > +end > > + > > +local function trace_const() > > + local counter = 0 > > + -- Run the inner trace several times. Before the patch, it leads > > + -- to several child traces due to the always failed guards. > > + while true do > > + if counter > 5 then break end > > + counter = counter + 1; > > + -- luacheck: ignore > > + for _ = 1, 1, -0 do > > + break > > + end > > + end > > +end > > + > > +local function test_trace_recorded(test_payload) > > + jit.flush() > > + -- Reset hotcounters. > nit: comment can be omitted I prefer not to. There may be the question: why we don't declare this parameters once? The reason is that the hotcounters may cause collisions and lead to the false-positive tests failures. Should I make the comment more verbose? > > + jit.opt.start('hotloop=1', 'hotexit=1') > > + test_payload() > > + return traceinfo(1) > > +end > > + > > +-- The -0 step leads to the always failed guard, so such traces > > +-- are now aborted and not recorded. > > + > > +test:ok(not test_trace_recorded(trace_slot), 'no trace recorded -0 as slot') > > +test:ok(not test_trace_recorded(trace_const), 'no trace recorded -0 as const') > > + > > +test:done(true) > > diff --git a/test/tarantool-tests/lj-1433-nan-for-control-var.test.lua b/test/tarantool-tests/lj-1433-nan-for-control-var.test.lua > > new file mode 100644 > > index 00000000..1f67f0ad > > --- /dev/null > > +++ b/test/tarantool-tests/lj-1433-nan-for-control-var.test.lua > > @@ -0,0 +1,79 @@ > > +local tap = require('tap') > > + > > +-- Test file to check the correct recording of for control > > +-- variable with NaN value. > > +-- See alsohttps://github.com/LuaJIT/LuaJIT/issues/1433. > > + > > +local test = tap.test('lj-1433-nan-for-control-var'):skipcond({ > > I would rename: > s/lj-1433-nan-for-control-var/lj-1433-nan-for-loop-control-var/ > > Feel free to ignore. Renamed here and the test name. =================================================================== diff --git a/test/tarantool-tests/lj-1433-nan-for-control-var.test.lua b/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua similarity index 96% rename from test/tarantool-tests/lj-1433-nan-for-control-var.test.lua rename to test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua index 1f67f0ad..fccd13c4 100644 --- a/test/tarantool-tests/lj-1433-nan-for-control-var.test.lua +++ b/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua @@ -4,7 +4,7 @@ local tap = require('tap') -- variable with NaN value. -- See also https://github.com/LuaJIT/LuaJIT/issues/1433. -local test = tap.test('lj-1433-nan-for-control-var'):skipcond({ +local test = tap.test('lj-1433-nan-for-loop-control-var'):skipcond({ ['Test requires JIT enabled'] = not jit.status(), }) =================================================================== > > > + ['Test requires JIT enabled'] = not jit.status(), > > +}) > > + > > +test:plan(3) > > + > > +local traceinfo = require('jit.util').traceinfo > > + > > +local function trace_nan_start() > > nit: s/trace_nan_start/trace_nan_loop_start/ > > the same below Renamed: =================================================================== diff --git a/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua b/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua index 63bbddcc..b9e5ad92 100644 --- a/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua +++ b/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua @@ -12,7 +12,7 @@ test:plan(3) local traceinfo = require('jit.util').traceinfo -local function trace_nan_start() +local function trace_nan_loop_start() local counter = 0 -- XXX: Use NaN as stack slot, not upvalue. local nan = 0 / 0 @@ -28,7 +28,7 @@ local function trace_nan_start() end end -local function trace_nan_stop() +local function trace_nan_loop_stop() local counter = 0 -- XXX: Use NaN as stack slot, not upvalue. local nan = 0 / 0 @@ -44,7 +44,7 @@ local function trace_nan_stop() end end -local function trace_nan_step() +local function trace_nan_loop_step() local counter = 0 -- XXX: Use NaN as stack slot, not upvalue. local nan = 0 / 0 @@ -71,9 +71,12 @@ end -- The NaN loop control vars leads to the always failed guard, so -- such traces are now aborted and not recorded. -test:ok(not test_trace_recorded(trace_nan_start), 'no trace recorded NaN start') -test:ok(not test_trace_recorded(trace_nan_stop), 'no trace recorded NaN stop') -test:ok(not test_trace_recorded(trace_nan_step), 'no trace recorded NaN step') +test:ok(not test_trace_recorded(trace_nan_loop_start), + 'no trace recorded NaN start') +test:ok(not test_trace_recorded(trace_nan_loop_stop), + 'no trace recorded NaN stop') +test:ok(not test_trace_recorded(trace_nan_loop_step), + 'no trace recorded NaN step') test:done(true) =================================================================== > > + local counter = 0 > > + -- XXX: Use NaN as stack slot, not upvalue. > > + local nan = 0 / 0 > > + -- Run the inner trace several times. Before the patch, it leads > > + -- to the trace with always fail guard. > > + while true do > > + if counter > 5 then break end > > + counter = counter + 1; > > + -- luacheck: ignore > > + for _ = nan, 1, 1 do > > + break > > + end > > + end > > +end > > + > > +local function trace_nan_stop() > > + local counter = 0 > > + -- XXX: Use NaN as stack slot, not upvalue. > > + local nan = 0 / 0 > > + -- Run the inner trace several times. Before the patch, it leads > > + -- to the trace with always fail guard. > > + while true do > > + if counter > 5 then break end > > + counter = counter + 1; > > + -- luacheck: ignore > > + for _ = 1, nan, 1 do > > + break > > + end > > + end > > +end > > + > > +local function trace_nan_step() > > + local counter = 0 > > + -- XXX: Use NaN as stack slot, not upvalue. > > + local nan = 0 / 0 > > + -- Run the inner trace several times. Before the patch, it leads > > + -- to several child traces due to the always failed guards. > > + while true do > > + if counter > 5 then break end > > + counter = counter + 1; > > + -- luacheck: ignore > > + for _ = 1, 1, nan do > > + break > > + end > > + end > > +end > > + > > +local function test_trace_recorded(test_payload) > > + jit.flush() > > + -- Reset hotcounters. > > + jit.opt.start('hotloop=1', 'hotexit=1') > > + test_payload() > > + return traceinfo(1) > > +end > > + > > +-- The NaN control vars leads to the always failed guard, so such > s/control/loop control/ Fixed. =================================================================== diff --git a/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua b/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua index fccd13c4..63bbddcc 100644 --- a/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua +++ b/test/tarantool-tests/lj-1433-nan-for-loop-control-var.test.lua @@ -68,8 +68,8 @@ local function test_trace_recorded(test_payload) return traceinfo(1) end --- The NaN control vars leads to the always failed guard, so such --- traces are now aborted and not recorded. +-- The NaN loop control vars leads to the always failed guard, so +-- such traces are now aborted and not recorded. test:ok(not test_trace_recorded(trace_nan_start), 'no trace recorded NaN start') test:ok(not test_trace_recorded(trace_nan_stop), 'no trace recorded NaN stop') =================================================================== > > +-- traces are now aborted and not recorded. > > + > > +test:ok(not test_trace_recorded(trace_nan_start), 'no trace recorded NaN start') > > +test:ok(not test_trace_recorded(trace_nan_stop), 'no trace recorded NaN stop') > > +test:ok(not test_trace_recorded(trace_nan_step), 'no trace recorded NaN step') > > + > > +test:done(true) > > + -- Best regards, Sergey Kaplun