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 0677C6ECD0; Tue, 30 Jun 2026 10:28:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0677C6ECD0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1782804533; bh=oJ4yfKtvpCSuk1eEGLreu+04sgEw+G5QYIE3pjPqp1g=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=hOSDYLSI+/kbhBA2ECYH2j5W8TuwEnT58bk4oAE2y8uNCmq1Z+noGADgk+6iFp32F w2hqYO6a5g4PaHNZJuHVB/jDZcdoU8XW/tgHTYPFIp7YXA2U/sv4FXh7ICnHDBUyrK ygcnFzu01Xm9mPGZVK4aPtE4/hwgcqGupW0MQrJI= Received: from send128.i.mail.ru (send128.i.mail.ru [89.221.237.223]) (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 99E0C6ECD0 for ; Tue, 30 Jun 2026 10:28:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 99E0C6ECD0 Received: by exim-smtp-78b8b8c574-vz9lr with esmtpa (envelope-from ) id 1weStm-00000000Ejn-1Od2; Tue, 30 Jun 2026 10:28:50 +0300 Content-Type: multipart/alternative; boundary="------------jWWvVaNGeblmqNeEsSWno40L" Message-ID: Date: Tue, 30 Jun 2026 10:28:49 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Evgeniy Temirgaleev References: <8855aae6-92fa-4fdd-80c8-541dd347fecf@tarantool.org> <1781536822.832174736@f756.i.mail.ru> Content-Language: en-US In-Reply-To: <1781536822.832174736@f756.i.mail.ru> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD918D6BB028DF8CB61F00B75217278B7BCC41E411AD4CF7748182A05F5380850407D0C4476357905563DE06ABAFEAF670558C866A307792F380FC207DFD489319540D08F30CB48EA5E X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79683A3C835791080EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB553375667C07923B88CEC0ED6A042AB77CCC63C62E2E5AFA775D479ED7BB6C4FD496AEFE389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C05A64D9A1E9CA65708941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6D07623A0E6354027CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249373C3576551F00B976E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8BFAEB00C13BDC9E8E3AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FCF1175FABE1C0F9B6E2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B8770A28E92C099B175ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A55E7010A3F672B3FA5002B1117B3ED69683B14A091838599FE99897350C7C491E823CB91A9FED034534781492E4B8EEAD0AA277257C6A5E3DBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6599F88942AD0C68DDB928A1989B5A8EF282BCFA65D9179E6E6546B92DA65DDF43A4A106957A385619CB8341EE9D5BE9A0A17D7EEAB8A3573FB5D9CAA9CBE7B0CC460FFB32A7A831BD6C7CEAA0681F5848F4C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVRSZSJkMhZtMVvPhFk/p7iA= X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F2588458F9511D5FBBC231D34825860F061DF2143F79698E41A1DA7B11066701245B7361645D15D82EE4B272BD6E4642A116CA93524AA66B5ACBE6721EF430B9A63E2A504198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Prevent sanitizer warnings for lj_tab_new*() and table.new(). 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 Cc: tarantool-patches@dev.tarantool.org, Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------jWWvVaNGeblmqNeEsSWno40L Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Evgeniy! thanks for review! Fixed and force-pushed: --- a/test/tarantool-tests/lj-1458-ub-table-new.test.lua +++ b/test/tarantool-tests/lj-1458-ub-table-new.test.lua @@ -15,7 +15,7 @@ local table_sizes = {    { INT_MAX, 0 },  } -test:plan(table_sizes * 2) +test:plan(#table_sizes * 2)  local table_new = require('table.new') Sergey On 6/15/26 18:20, Evgeniy Temirgaleev wrote: > Hi, Sergey! Thanks for the patch! > LGTM after fixing a typo: > -test:plan(table_sizes * 2) > +test:plan(#table_sizes * 2) > -- > Best regards, > Evgeniy Temirgaleev > > From: Sergey Bronnikov via Tarantool-patches > > To: Sergey Kaplun , Sergey Bronnikov > > Cc:tarantool-patches@dev.tarantool.org > Date: Wednesday, June 10, 2026 4:21 PM +03:00 > > Hi, Sergey, > > thanks for the review. Fixes applied and force-pushed. > > Sergey > > On 6/9/26 15:03, Sergey Kaplun via Tarantool-patches wrote: >> Hi, Sergey! >> Thanks for the patch! >> LGTM, after fixing a few nits below. >> >> On 09.06.26, Sergey Bronnikov wrote: >>> From: Mike Pall >>> >>> Reported by Sergey Bronnikov. >>> >>> (cherry picked from commit 8f421c81ec6aaae0bcd80e01f4353de200afbbc5) >>> >>> The Undefined Behaviour Sanitizer [1] produce a warning because >> Typo: s/produce/produces/ > > Fixed. > >> >>> the function `lua_createtable()` takes signed integer arguments, >>> but the `lj_tab_new_ah()` was not properly validating or converting >>> these signed values before using them in unsigned arithmetic. >>> >>> The fix changes the signature of `lj_tab_new_ah()` to accept >>> uint32_t directly, and adjusts `lua_createtable()` to cast the >>> incoming signed int values to uint32_t before passing them. >>> >>> [1]:https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html >>> >>> Sergey Bronnikov: >>> * added the description and the test for the problem >>> >>> Part of tarantool/tarantool#12480 >>> --- >>> Branch:https://github.com/tarantool/luajit/tree/ligurio/lj-1458-ub-lj_tab_new >>> >>> Related issues: >>> -https://github.com/tarantool/tarantool/issues/12480 >>> -https://github.com/LuaJIT/LuaJIT/issues/1458 >>> >>> >>> src/lj_api.c | 2 +- >>> src/lj_tab.c | 4 +-- >>> src/lj_tab.h | 2 +- >>> .../lj-1458-ub-table.new.test.lua | 30 +++++++++++++++++++ >>> 4 files changed, 34 insertions(+), 4 deletions(-) >>> create mode 100644 test/tarantool-tests/lj-1458-ub-table.new.test.lua >>> >> >> >>> diff --git a/test/tarantool-tests/lj-1458-ub-table.new.test.lua b/test/tarantool-tests/lj-1458-ub-table.new.test.lua >>> new file mode 100644 >>> index 00000000..d0cf6ff5 >>> --- /dev/null >>> +++ b/test/tarantool-tests/lj-1458-ub-table.new.test.lua >> Typo: s/table.new/table-new/ > Fixed. >> >>> @@ -0,0 +1,30 @@ >>> +local tap = require('tap') >>> + >>> +-- The test file to demonstrate UBSan warning for `table.new()` >>> +-- with a minimal and maximum array and hash parts values. >>> +-- See also:https://github.com/LuaJIT/LuaJIT/issues/1458. >>> +local test = tap.test('lj-1458-ub-table-new') >>> + >>> +test:plan(8) >> Lets use table_sizes * 2 here. >> > Updated. > >>> + >>> +local table_new = require('table.new') >>> + >>> +local INT_MAX = 2 ^ 31 - 1 >>> +local INT_MIN = -2 ^ 31 >>> + >>> +local table_sizes = { >>> + { 0, INT_MIN }, >>> + { 0, INT_MAX }, >>> + { INT_MIN, 0 }, >>> + { INT_MAX, 0 }, >>> +} >>> + >>> +for _, case in ipairs(table_sizes) do >>> + local apart, hpart = unpack(case) >>> + local ok, err = pcall(table_new, apart, hpart) >>> + local message = ('table.new(%d, %d)'):format(apart, hpart) >>> +test:is(ok, false, message .. ' is failed') >> Typo? s/failed/OK/ > > Right, fixed: > > --- a/test/tarantool-tests/lj-1458-ub-table-new.test.lua > +++ b/test/tarantool-tests/lj-1458-ub-table-new.test.lua > @@ -23,7 +23,7 @@ for _, case in ipairs(table_sizes) do >    local apart, hpart = unpack(case) >    local ok, err = pcall(table_new, apart, hpart) >    local message = ('table.new(%d, %d)'):format(apart, hpart) > - test:is(ok, false, message .. ' is failed') > + test:is(ok, false, message .. ' is ok') > test:ok(err:match('table overflow'), message .. ' correct error > message') >  end > >> >>> +test:ok(err:match('table overflow'), message .. ' correct error message') >>> +end >>> + >>> +test:done(true) >>> -- >>> 2.43.0 >>> >> > --------------jWWvVaNGeblmqNeEsSWno40L Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Evgeniy!

thanks for review!

Fixed and force-pushed:

--- a/test/tarantool-tests/lj-1458-ub-table-new.test.lua
+++ b/test/tarantool-tests/lj-1458-ub-table-new.test.lua
@@ -15,7 +15,7 @@ local table_sizes = {
   { INT_MAX, 0 },
 }
 
-test:plan(table_sizes * 2)
+test:plan(#table_sizes * 2)
 
 local table_new = require('table.new')
 

Sergey

On 6/15/26 18:20, Evgeniy Temirgaleev wrote:
Hi, Sergey! Thanks for the patch!
 
LGTM after fixing a typo:
 
-test:plan(table_sizes * 2)
+test:plan(#table_sizes * 2)
 
--
Best regards,
Evgeniy Temirgaleev

From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>, Sergey Bronnikov <estetus@gmail.com>
Cc:tarantool-patches@dev.tarantool.org
Date: Wednesday, June 10, 2026 4:21 PM +03:00

 

Hi, Sergey,

thanks for the review. Fixes applied and force-pushed.

Sergey

On 6/9/26 15:03, Sergey Kaplun via Tarantool-patches wrote:
Hi, Sergey!
Thanks for the patch!
LGTM, after fixing a few nits below.

On 09.06.26, Sergey Bronnikov wrote:
From: Mike Pall <mike>

Reported by Sergey Bronnikov.

(cherry picked from commit 8f421c81ec6aaae0bcd80e01f4353de200afbbc5)

The Undefined Behaviour Sanitizer [1] produce a warning because
Typo: s/produce/produces/

Fixed.

 

 
the function `lua_createtable()` takes signed integer arguments,
but the `lj_tab_new_ah()` was not properly validating or converting
these signed values before using them in unsigned arithmetic.

The fix changes the signature of `lj_tab_new_ah()` to accept
uint32_t directly, and adjusts `lua_createtable()` to cast the
incoming signed int values to uint32_t before passing them.

[1]: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

Sergey Bronnikov:
* added the description and the test for the problem

Part of tarantool/tarantool#12480
---
Branch: https://github.com/tarantool/luajit/tree/ligurio/lj-1458-ub-lj_tab_new

Related issues:
- https://github.com/tarantool/tarantool/issues/12480
- https://github.com/LuaJIT/LuaJIT/issues/1458


 src/lj_api.c                                  |  2 +-
 src/lj_tab.c                                  |  4 +--
 src/lj_tab.h                                  |  2 +-
 .../lj-1458-ub-table.new.test.lua             | 30 +++++++++++++++++++
 4 files changed, 34 insertions(+), 4 deletions(-)
 create mode 100644 test/tarantool-tests/lj-1458-ub-table.new.test.lua

<snipped>

diff --git a/test/tarantool-tests/lj-1458-ub-table.new.test.lua b/test/tarantool-tests/lj-1458-ub-table.new.test.lua
new file mode 100644
index 00000000..d0cf6ff5
--- /dev/null
+++ b/test/tarantool-tests/lj-1458-ub-table.new.test.lua
Typo: s/table.new/table-new/
Fixed.
 
@@ -0,0 +1,30 @@
+local tap = require('tap')
+
+-- The test file to demonstrate UBSan warning for `table.new()`
+-- with a minimal and maximum array and hash parts values.
+-- See also: https://github.com/LuaJIT/LuaJIT/issues/1458.
+local test = tap.test('lj-1458-ub-table-new')
+
+test:plan(8)
Lets use table_sizes * 2 here.

Updated.

 

 

+
+local table_new = require('table.new')
+
+local INT_MAX =  2 ^ 31 - 1
+local INT_MIN = -2 ^ 31
+
+local table_sizes = {
+  { 0, INT_MIN },
+  { 0, INT_MAX },
+  { INT_MIN, 0 },
+  { INT_MAX, 0 },
+}
+
+for _, case in ipairs(table_sizes) do
+  local apart, hpart = unpack(case)
+  local ok, err = pcall(table_new, apart, hpart)
+  local message = ('table.new(%d, %d)'):format(apart, hpart)
+  test:is(ok, false, message .. ' is failed')
Typo? s/failed/OK/

 

Right, fixed:

--- a/test/tarantool-tests/lj-1458-ub-table-new.test.lua
+++ b/test/tarantool-tests/lj-1458-ub-table-new.test.lua
@@ -23,7 +23,7 @@ for _, case in ipairs(table_sizes) do
   local apart, hpart = unpack(case)
   local ok, err = pcall(table_new, apart, hpart)
   local message = ('table.new(%d, %d)'):format(apart, hpart)
test:is(ok, false, message .. ' is failed')
test:is(ok, false, message .. ' is ok')
   test:ok(err:match('table overflow'), message .. ' correct error message')
 end
 

 
+  test:ok(err:match('table overflow'), message .. ' correct error message')
+end
+
+test:done(true)
-- 
2.43.0

 
--------------jWWvVaNGeblmqNeEsSWno40L--