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 CAA731B56998; Mon, 30 Mar 2026 15:29:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CAA731B56998 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1774873798; bh=Mxxjrdf1xhclOVXFbWbVzcRKS2WObqOe30yZPIcyqvE=; 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=aC1kK1HVE1Xr627Os3m0TV9oK7U7Qxmz/5n8PNOwlyppoUnuZy6s4DYK4WkzIx0lN qZsqiU0b2zbXhjw5//umM4ZTzzm0QB7TDcmO3QTGNwR9YDUQ9oR0zI0SJSYVJ7s1wr 4MAHP5PEg5n9I8W25NTjmQ7q0CrP8R7w0ksrbgG4= Received: from send126.i.mail.ru (send126.i.mail.ru [89.221.237.221]) (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 5A9E51B5699B for ; Mon, 30 Mar 2026 15:29:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5A9E51B5699B Received: by exim-smtp-74865f89dd-gjpcq with esmtpa (envelope-from ) id 1w7Bki-00000000LCa-1DxL; Mon, 30 Mar 2026 15:29:56 +0300 Date: Mon, 30 Mar 2026 15:30:53 +0300 To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Message-ID: References: <7183dd75158a7191fc2b08ae43e17e4f3d1afcf2.1774870754.git.sergeyb@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7183dd75158a7191fc2b08ae43e17e4f3d1afcf2.1774870754.git.sergeyb@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9BB347BE606964F7A26E4059BD9997A6DE9B3E15BE9F949E2182A05F5380850401A5B826E0B0B283B3DE06ABAFEAF6705470DF907D3F3F83B6941A9CE1E327206E4D98B9586BF5A92 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F544D30F1A6FA191EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FE9EFE935CD7C6AE8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2E8E38D7D389D92932E070BE324C7D3C4CAD48335422ADA92F6B57BC7E64490618DEB871D839B73339E8FC8737B5C22498CC5112E3E56BCDBCC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C0B9A0B17A9DBCC47B8941B15DA834481F9449624AB7ADAF37BA3038C0950A5D3613377AFFFEAFD269176DF2183F8FC7C0872F3B397916FE8B7B076A6E789B0E97A8DF7F3B2552694AD5FFEEA1DED7F25D49FD398EE364050F140C956E756FBB7A452896749CDDA0A6B3661434B16C20ACC84D3B47A649675FE827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BDCE939D40DBB93CA75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A5A64FBFE899BC6FD35002B1117B3ED69689844D5F26A6716DA9DAB4B68AE4D22F823CB91A9FED034534781492E4B8EEAD0942DC5495D0595EBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6598B2628AEDAFFCF2EE42F52FD1F4E73FF4E947B5391D0BD527EAD69A1B80D826367CA287D23F34AB9B8341EE9D5BE9A0AABB399E27B414EC5721DFC1C1319955F24A3D8825EAB434F8CD93680B12512CF4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdx/hWl0/CTmOqy6ZgEU/MU= X-Mailru-Sender: 520A125C2F17F0B17094CDC02B85F11BA19F2F1D1AB5D83A3DE06ABAFEAF6705470DF907D3F3F83BB7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Prevent false positive sanitizer warning in unpack(). 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 patch! LGTM, after fixing my minor comments below. On 30.03.26, Sergey Bronnikov wrote: > From: Mike Pall > > Reported by Sergey Bronnikov. > > (cherry picked from commit f322ecb51e3cea06683cc201e8ce224ec42fdab8) > > The UndefinedBehaviour sanitizer produce a runtime warning when Typo: s/produce/produces/ > INT_MAX is passed to `unpack()` as index `j`. This happens because Typo: s/j/i/ > `i` in lj_cf_unpack() was incremented before the checking loop > invariant and this could to a signed integer overflo. The patch Typo: s/could to/leads to/ Typo: s/overflo/overflow/ > fixes the issue by moving a loop invariant to a loop body. Minor: It is rather "by moving index incrementation in the separate statement from the loop invariant check". > > Sergey Bronnikov: > * added the description and the test for the problem > > Part of tarantool/tarantool#12134 > --- > > Branch: https://github.com/tarantool/luajit/tree/ligurio/lj-1450-unpack-ub > Related issues: > * https://github.com/LuaJIT/LuaJIT/issues/1450 > * https://github.com/tarantool/tarantool/issues/12134 > > src/lib_base.c | 4 ++- > .../lj-1450-unpack-huge-indices.test.lua | 28 +++++++++++++++++++ > 2 files changed, 31 insertions(+), 1 deletion(-) > create mode 100644 test/tarantool-tests/lj-1450-unpack-huge-indices.test.lua > > diff --git a/src/lib_base.c b/src/lib_base.c > index a5b907de..714dc5bf 100644 > --- a/src/lib_base.c > +++ b/src/lib_base.c > diff --git a/test/tarantool-tests/lj-1450-unpack-huge-indices.test.lua b/test/tarantool-tests/lj-1450-unpack-huge-indices.test.lua > new file mode 100644 > index 00000000..1a09e273 > --- /dev/null > +++ b/test/tarantool-tests/lj-1450-unpack-huge-indices.test.lua > @@ -0,0 +1,28 @@ > +local tap = require('tap') > + > +-- The test file to demonstrate UBSan warning for `unpack()` with > +-- a huge indices value. > +-- See also: https://github.com/LuaJIT/LuaJIT/issues/1450. > +local test = tap.test('lj-1450-unpack-huge-indices') > + > +test:plan(4) > + > +local INT_MAX = 2 ^ 31 - 1 > + > +-- The first test check the UBSan runtime error. The assertions Typo: s/check/checks/ > +-- were added just to be sure we don't change the behaviour. > +-- The second test additionally check a correct behaviour for Typo: s/check/checks/ > +-- a value. > +local tbl = { > + [INT_MAX] = INT_MAX, > + [INT_MAX - 1] = INT_MAX - 1, I suggest creating for this value the `INT_MAX_M1` variable. Feel free to ignore. > +} > +local status, res = pcall(unpack, tbl, INT_MAX, INT_MAX) `pcall()`-s look excessive here since we always expect only 1 element to be unpacked, so we obviously have enough space for it. Let's drop them. > +test:ok(status, 'unpack with INT_MAX: correct status') > +test:is(res, INT_MAX, 'unpack with INT_MAX: correct result') > + > +status, res = pcall(unpack, tbl, INT_MAX - 1, INT_MAX - 1) > +test:ok(status, 'unpack with INT_MAX - 1: correct status') > +test:is(res, INT_MAX - 1, 'unpack with INT_MAX - 1: correct result') > + > +test:done(true) > -- > 2.43.0 > -- Best regards, Sergey Kaplun