<HTML><BODY><div class="cl-6xno9ogmdm"><div>Hi, Sergey! Thanks for the patch!</div><div> </div><div>LGTM after fixing a typo:</div><div> </div><div><div><div>-test:plan(table_sizes * 2)</div><div>+test:plan(#table_sizes * 2)</div></div><div> </div></div><div data-signature-widget="container"><div data-signature-widget="content"><div>--<br>Best regards,</div><div>Evgeniy Temirgaleev</div></div></div><br><div class="mail-quote-collapse"><blockquote style="border-left:1px solid #0857A6;margin:10px;padding:0 0 0 10px"><span>From: Sergey Bronnikov via Tarantool-patches <<a href="mailto:tarantool-patches@dev.tarantool.org">tarantool-patches@dev.tarantool.org</a>><br>To: Sergey Kaplun <<a href="mailto:skaplun@tarantool.org">skaplun@tarantool.org</a>>, Sergey Bronnikov <<a href="mailto:estetus@gmail.com">estetus@gmail.com</a>><br>Cc:<a href="mailto:tarantool-patches@dev.tarantool.org">tarantool-patches@dev.tarantool.org</a><br>Date: Wednesday, June 10, 2026 4:21 PM +03:00</span><br> <div><div id=""><div class="cl-g3ckeggni8"><div class="js-helper_mr_css_attr js-readmsg-msg_mr_css_attr"><div id="style_17810977151719212730_mr_css_attr"><div id="style_17810977151719212730_BODY_mr_css_attr"><p>Hi, Sergey,</p><p>thanks for the review. Fixes applied and force-pushed.</p><p>Sergey</p><div class="moz-cite-prefix_mr_css_attr">On 6/9/26 15:03, Sergey Kaplun via Tarantool-patches wrote:</div><blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr">Hi, Sergey!
Thanks for the patch!
LGTM, after fixing a few nits below.
On 09.06.26, Sergey Bronnikov wrote:
</pre><blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr">From: Mike Pall <mike>
Reported by Sergey Bronnikov.
(cherry picked from commit 8f421c81ec6aaae0bcd80e01f4353de200afbbc5)
The Undefined Behaviour Sanitizer [1] produce a warning because
</pre></blockquote><pre class="moz-quote-pre_mr_css_attr">Typo: s/produce/produces/</pre></blockquote><p>Fixed.</p><p> </p><blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr"> </pre><blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr">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]: <a href="https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html" class="moz-txt-link-freetext_mr_css_attr">https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html</a>
Sergey Bronnikov:
* added the description and the test for the problem
Part of tarantool/tarantool#12480
---
Branch: <a href="https://github.com/tarantool/luajit/tree/ligurio/lj-1458-ub-lj_tab_new" class="moz-txt-link-freetext_mr_css_attr">https://github.com/tarantool/luajit/tree/ligurio/lj-1458-ub-lj_tab_new</a>
Related issues:
- <a href="https://github.com/tarantool/tarantool/issues/12480" class="moz-txt-link-freetext_mr_css_attr">https://github.com/tarantool/tarantool/issues/12480</a>
- <a href="https://github.com/LuaJIT/LuaJIT/issues/1458" class="moz-txt-link-freetext_mr_css_attr">https://github.com/LuaJIT/LuaJIT/issues/1458</a>
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
</pre></blockquote><pre class="moz-quote-pre_mr_css_attr"><snipped>
</pre><blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr">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
</pre></blockquote><pre class="moz-quote-pre_mr_css_attr">Typo: s/table.new/table-new/</pre></blockquote>Fixed.<blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr"> </pre><blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr">@@ -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: <a href="https://github.com/LuaJIT/LuaJIT/issues/1458" class="moz-txt-link-freetext_mr_css_attr">https://github.com/LuaJIT/LuaJIT/issues/1458</a>.
+local test = tap.test('lj-1458-ub-table-new')
+
+test:plan(8)
</pre></blockquote><pre class="moz-quote-pre_mr_css_attr">Lets use table_sizes * 2 here.
</pre></blockquote><p>Updated.</p></div></div></div></div></div></div></blockquote></div></div><div class="cl-6xno9ogmdm"><div class="mail-quote-collapse"><blockquote style="border-left:1px solid #0857A6;margin:10px;padding:0 0 0 10px"><div><div><div class="cl-g3ckeggni8"><div class="js-helper_mr_css_attr js-readmsg-msg_mr_css_attr"><div><div><p> </p><p> </p><blockquote type="cite"><blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr">+
+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)
+ <a class="moz-txt-link-freetext_mr_css_attr">test:is(ok</a>, false, message .. ' is failed')
</pre></blockquote><pre class="moz-quote-pre_mr_css_attr">Typo? s/failed/OK/</pre></blockquote><p> </p><p>Right, fixed:</p><p>--- a/test/tarantool-tests/lj-1458-ub-table-new.test.lua<br>+++ b/test/tarantool-tests/lj-1458-ub-table-new.test.lua<br>@@ -23,7 +23,7 @@ for _, case in ipairs(table_sizes) do<br> local apart, hpart = unpack(case)<br> local ok, err = pcall(table_new, apart, hpart)<br> local message = ('table.new(%d, %d)'):format(apart, hpart)<br>- <a class="moz-txt-link-freetext_mr_css_attr">test:is(ok</a>, false, message .. ' is failed')<br>+ <a class="moz-txt-link-freetext_mr_css_attr">test:is(ok</a>, false, message .. ' is ok')<br> <a class="moz-txt-link-freetext_mr_css_attr">test:ok(err:match('table</a> overflow'), message .. ' correct error message')<br> end<br> </p><blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr"> </pre><blockquote type="cite"><pre class="moz-quote-pre_mr_css_attr">+ <a class="moz-txt-link-freetext_mr_css_attr">test:ok(err:match('table</a> overflow'), message .. ' correct error message')
+end
+
+test:done(true)
--
2.43.0
</pre></blockquote><pre class="moz-quote-pre_mr_css_attr"> </pre></blockquote></div></div></div></div></div></div></blockquote></div></div></BODY></HTML>