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 402316ECCC; Wed, 10 Jun 2026 14:03:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 402316ECCC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1781089428; bh=IKZc+Z0tiLjh+x7JUYm3jNWAbvl3fyOwsvrbXRf1rmU=; 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=ZjnzOeXzYSot0ZEmssrSfP3TiVWJwhWon4q8wkHw7WSsIJQW/uHs9W04szLqiNnpy Sa7DW0YY5q01FQtLh2UA68s/v1h4LX82wiB7D5uN2OP76eLD5vlQYhvsStu/qbr3nH YnciTKnkzFZfHSesCPI//uErC7FflJKIqQk1T3rk= Received: from send175.i.mail.ru (send175.i.mail.ru [95.163.59.14]) (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 76C406ECCC for ; Wed, 10 Jun 2026 14:03:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 76C406ECCC Received: by exim-smtp-5bf699dc9d-w7t64 with esmtpa (envelope-from ) id 1wXGin-00000000Phm-1FFp; Wed, 10 Jun 2026 14:03:45 +0300 Content-Type: multipart/alternative; boundary="------------EDVWTp3btc9hGHtuzm7EdpPu" Message-ID: <8855aae6-92fa-4fdd-80c8-541dd347fecf@tarantool.org> Date: Wed, 10 Jun 2026 14:03:44 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org References: In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9E926CE86FFF978D78EA92D1D69FA9C32166AEEAEEAA5959B182A05F53808504025CD0875E8EDB7BF3DE06ABAFEAF67057AF855A52806B5B67A2EDF80B10911C8492007A4EDD3F072 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7747FD4AFDBA6C67AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566C4A2DDB517F39A9D59EE37C0F09CA0B90FB91A53241C655FFB163D62B327A6F9389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C05A64D9A1E9CA65708941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6B737A621A50BC793CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF17B107DEF921CE791DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C361DD96311B40C2D435872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A56B5AF50558F3E84C5002B1117B3ED696A5F7C80E04E12AA08D59E407A97E9958823CB91A9FED034534781492E4B8EEADC3194D76C41E9723BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6594975E8D6E9611BBC781394879F46C4250685721EA2D1F55DC12472783808B693FE495A458FFF380EB8341EE9D5BE9A0A4B6FC0B03762B0E51C40C10AFAD2DEC906A219875440F3EE6536EB022892E5344C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVfwaKBAd4IJXwBLVoIGs2cA= X-DA7885C5: BC348844F5CAAFFEF255D290C0D534F9867A8DA1D3413918F6BEAEB9BBEE9DC78C0E15670FAD76BF5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393520AF17B8A65FDE211504E4A5DCB95B8ABDC1BD89FF5937C8042AD8E2E1912D3EF86D5F70DA33880E41E8EF7A07863ECB274557F927329BE2DDF8182D28ACDB545BD1C3CC395C826B4A721A3011E896F 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------EDVWTp3btc9hGHtuzm7EdpPu Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 >> --------------EDVWTp3btc9hGHtuzm7EdpPu Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

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


    
--------------EDVWTp3btc9hGHtuzm7EdpPu--