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 A63BD6ECDC; Tue, 9 Jun 2026 15:03:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A63BD6ECDC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1781006631; bh=gzHJ4so4ed3gb7rBdfI+ai+doausf9i4mYrcEPCQ+ao=; 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=F9piHZlnJ4hCcAYWI7CNL8/tQ1rqVSUNW8o1Y/eZn1RU5Kp46+AdpfUx+KdjpPJk1 JjubVVAB/TJpt28YcLPwitYl788D1hVCeN1t+nsFgl/Li+7hbzpJS/KfhpmnjUGcdC ubyZvsJp6eMB53yjcv4/jl/xNZ7BsUxshkh2IP/4= Received: from send277.i.mail.ru (send277.i.mail.ru [95.163.59.116]) (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 838C96ECDC for ; Tue, 9 Jun 2026 15:03:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 838C96ECDC Received: by exim-smtp-5bf699dc9d-f6c6s with esmtpa (envelope-from ) id 1wWvBN-00000000FuM-2Fq9; Tue, 09 Jun 2026 15:03:50 +0300 Date: Tue, 9 Jun 2026 15:03:15 +0300 To: Sergey Bronnikov Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9AC1F4C666D2CC1E7272CF49B7F37D1142B12043362BF2099182A05F53808504013F9189844C432A13DE06ABAFEAF67051ADE83B2ED231DEEC98249E4D794783BDAF06271CF5AE1BC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C8DD139BC0BB8586EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FE9EFE935CD7C6AE8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2995DFD55944CCD082E070BE324C7D3C40B0062223AAB94FCF6B57BC7E64490618DEB871D839B73339E8FC8737B5C2249E232F00D8D26902CA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F28451B159A507268D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6AC294AFEFA671E80089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5F829597C86E888E65002B1117B3ED696BCC04A6AA7FA4AA0559C6C5561145D6F823CB91A9FED034534781492E4B8EEAD0D89974173551D4FBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D65945B5307C7176C69991B34ADCCC4B1C531CAD386A5948CC69E7F39A658FAD2A0362D9211F2D7BE15EB8341EE9D5BE9A0A5217E3BA0723119496EAEEF5B76A9C24CD4132D725B650B16536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVfwaKBAd4IJXhfrYqlud/IA= X-DA7885C5: E3E0F621FB6D3815F255D290C0D534F9069C544502ABDEA7ED3308014C1DC5FAFB5DC8D5C40F92835B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393520AF17B8A65FDE2458F24ADFCA7E56853FAC6DFF580BB007096636A9E7436DEE49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F 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 Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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/ > 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/ > @@ -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. > + > +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/ > + test:ok(err:match('table overflow'), message .. ' correct error message') > +end > + > +test:done(true) > -- > 2.43.0 > -- Best regards, Sergey Kaplun