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 858B06EC40; Mon, 8 Jun 2026 13:59:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 858B06EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1780916371; bh=3JVKu4C0te9eFr0LuhhN0Ne/tUO2Ap0bAn3GF0JNib4=; 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=dynrKpe3et3mtLRZZ5J+TzddL4ERv7Q9E+XbfVwM++uBxCznp/rvpSuqpKF+gxOpf o5FtfEShH92qdj/k46mfrcwI5BKu9QmHyDt4u2fsztogg4TYBW+kjYZ9I+2HTR7eTi 9S6oaZMUZKY1SofUwHZm900ktZZyjnTDwDY9b0pg= Received: from send149.i.mail.ru (send149.i.mail.ru [89.221.237.244]) (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 098616EC40 for ; Mon, 8 Jun 2026 13:59:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 098616EC40 Received: by exim-smtp-58b66f8686-lnb2g with esmtpa (envelope-from ) id 1wWXhY-000000002FY-3mac; Mon, 08 Jun 2026 13:59:29 +0300 Content-Type: multipart/alternative; boundary="------------Su2YvJ3IHXD4msQ0z0WLGcLM" Message-ID: Date: Mon, 8 Jun 2026 13:59:27 +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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD94224184159A306D4BBDBF96C5B91AD48FAF7310D62CF5C8B00894C459B0CD1B9F9806B7A4BE4EE5EF378A8CA21F699D6FADC06585DC66E52F839FC06871EB46DED199C4BD4F2E418 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B9FBA884A7C9B8BAEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB5533756637AB5DC418F5BF14A0452C205C567A92F5BA58311BE15FDC26779231CE389C7B389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0A29E2F051442AF778941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6D52CD31C43BF465FCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7AEA1580DED4E70E3731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A55542F8AB6D90C4605002B1117B3ED6961DE15A78C4252624C89B063BDC7FAC35823CB91A9FED034534781492E4B8EEADEEA082C9A12FE455BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F96AB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659A59A6904894285B98C9917781FBD2D410D2C7BFCE529528257E79CFD0712BC99A81C360B97DFA67AB8341EE9D5BE9A0A8BF47912CC781C21C75B7BAE0A21167E85BE7DB338D878976536EB022892E5344C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVRI2994ruhLUeuDwocmyi/k= X-DA7885C5: 71230E62F1B89A67F255D290C0D534F9AE737F1EC53BD8EE173A468804FAED8A112F48D230E51AB75B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393520AF17B8A65FDE2C6D27A8BA8635534D46BC8D9960C5602F42DD4AE2D90D301EF86D5F70DA33880E41E8EF7A07863ECB274557F927329BE2DDF8182D28ACDB545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Prevent sanitizer warning in os.time(). 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. --------------Su2YvJ3IHXD4msQ0z0WLGcLM Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Sergey, thanks for the review! See my comments below. Sergey On 6/6/26 10:14, Sergey Kaplun via Tarantool-patches wrote: > Hi, Sergey! > Thanks for the patch! > LGTM, with minor ignorable comments below. > > On 05.06.26, Sergey Bronnikov wrote: >> From: Mike Pall >> >> Reported by Sergey Bronnikov. >> >> (cherry picked from commit 86d414f5cae062b06998ec66b0696a47d4f6a0f0) >> >> The function `lj_cf_os_time()` calculates `tm_mon` and `tm_year` >> values using `get_field()` and when the helper function returns >> a negative value the resulted values may be negative as well. This >> is an undefined behaviour (signed integer overflow). The patch fixes >> that by adding a cast for the resulted value to returned by > Typo: s/to returned/to be returned/ Fixed. > >> `get_field()`. > I am suggesting rephrasing this paragraph a bit to make it more clear: > > | The function `lj_cf_os_time()` calculates the `tm_mon` and `tm_year` > | values using `get_field()`. If this helper function returns a negative > | result, subtraction may lead to undefined behavior due to signed integer > | overflow. The patch fixes the issue by adding a cast to the value > | returned by `get_field()`. > > Feel free to ignore. Updated. > >> 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-1454-ub-os-time >> >> Related issues: >> >> *https://github.com/tarantool/tarantool/issues/12480 >> *https://github.com/LuaJIT/LuaJIT/issues/1454 >> >> src/lib_os.c | 4 ++-- >> test/tarantool-tests/lj-1454-os-time.test.lua | 19 +++++++++++++++++++ >> 2 files changed, 21 insertions(+), 2 deletions(-) >> create mode 100644 test/tarantool-tests/lj-1454-os-time.test.lua >> >> diff --git a/src/lib_os.c b/src/lib_os.c >> index ffbc3fdc..0feb0d47 100644 >> --- a/src/lib_os.c >> +++ b/src/lib_os.c > > >> diff --git a/test/tarantool-tests/lj-1454-os-time.test.lua b/test/tarantool-tests/lj-1454-os-time.test.lua >> new file mode 100644 >> index 00000000..2a48750c >> --- /dev/null >> +++ b/test/tarantool-tests/lj-1454-os-time.test.lua > I prefer the name (as you named the > branch). Feel free to ignore. Updated: $ git show --name-only src/lib_os.c test/tarantool-tests/lj-1454-ub-os-time.test.lua >> @@ -0,0 +1,19 @@ >> +local tap = require('tap') >> + >> +-- The test file to demonstrate UBSan warning for `os.time()` with >> +-- a huge indices value for month and/or year. > s/a huge indices value/huge negative index values/ Updated: --- a/test/tarantool-tests/lj-1454-ub-os-time.test.lua +++ b/test/tarantool-tests/lj-1454-ub-os-time.test.lua @@ -1,7 +1,7 @@  local tap = require('tap')  -- The test file to demonstrate UBSan warning for `os.time()` with --- a huge indices value for month and/or year. +-- huge negative index values for month and/or year.  -- See also: https://github.com/LuaJIT/LuaJIT/issues/1454.  local test = tap.test('lj-1454-os-time') > >> +-- See also:https://github.com/LuaJIT/LuaJIT/issues/1454. >> +local test = tap.test('lj-1454-os-time') > I prefer the lj-1454-ub-os-time name (as you named the branch). Feel > free to ignore. Updated:  -- See also: https://github.com/LuaJIT/LuaJIT/issues/1454. -local test = tap.test('lj-1454-os-time') +local test = tap.test('lj-1454-ub-os-time') test:plan(1) > >> + >> +test:plan(1) >> + >> +local INT_MIN = -2 ^ 31 >> + >> +local cur_time = os.time({ >> + day = 1, >> + month = INT_MIN, >> + year = INT_MIN, >> +}) >> +test:is(cur_time, nil, 'os.time() with INT_MIN') >> + >> +test:done(true) >> -- >> 2.43.0 >> --------------Su2YvJ3IHXD4msQ0z0WLGcLM Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Sergey,

thanks for the review! See my comments below.

Sergey

On 6/6/26 10:14, Sergey Kaplun via Tarantool-patches wrote:
Hi, Sergey!
Thanks for the patch!
LGTM, with minor ignorable comments below.

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

Reported by Sergey Bronnikov.

(cherry picked from commit 86d414f5cae062b06998ec66b0696a47d4f6a0f0)

The function `lj_cf_os_time()` calculates `tm_mon` and `tm_year`
values using `get_field()` and when the helper function returns
a negative value the resulted values may be negative as well. This
is an undefined behaviour (signed integer overflow). The patch fixes
that by adding a cast for the resulted value to returned by
Typo: s/to returned/to be returned/
Fixed.

`get_field()`.
I am suggesting rephrasing this paragraph a bit to make it more clear:

| The function `lj_cf_os_time()` calculates the `tm_mon` and `tm_year`
| values using `get_field()`. If this helper function returns a negative
| result, subtraction may lead to undefined behavior due to signed integer
| overflow. The patch fixes the issue by adding a cast to the value
| returned by `get_field()`.

Feel free to ignore.
Updated.

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-1454-ub-os-time

Related issues:

* https://github.com/tarantool/tarantool/issues/12480
* https://github.com/LuaJIT/LuaJIT/issues/1454

 src/lib_os.c                                  |  4 ++--
 test/tarantool-tests/lj-1454-os-time.test.lua | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 test/tarantool-tests/lj-1454-os-time.test.lua

diff --git a/src/lib_os.c b/src/lib_os.c
index ffbc3fdc..0feb0d47 100644
--- a/src/lib_os.c
+++ b/src/lib_os.c
<snipped>

diff --git a/test/tarantool-tests/lj-1454-os-time.test.lua b/test/tarantool-tests/lj-1454-os-time.test.lua
new file mode 100644
index 00000000..2a48750c
--- /dev/null
+++ b/test/tarantool-tests/lj-1454-os-time.test.lua
I prefer the <lj-1454-ub-os-time.test.lua> name (as you named the
branch). Feel free to ignore.

Updated:

$ git show --name-only 

<snipped>
src/lib_os.c
test/tarantool-tests/lj-1454-ub-os-time.test.lua


      
@@ -0,0 +1,19 @@
+local tap = require('tap')
+
+-- The test file to demonstrate UBSan warning for `os.time()` with
+-- a huge indices value for month and/or year.
s/a huge indices value/huge negative index values/

Updated:

--- a/test/tarantool-tests/lj-1454-ub-os-time.test.lua
+++ b/test/tarantool-tests/lj-1454-ub-os-time.test.lua
@@ -1,7 +1,7 @@
 local tap = require('tap')
 
 -- The test file to demonstrate UBSan warning for `os.time()` with
--- a huge indices value for month and/or year.
+-- huge negative index values for month and/or year.
 -- See also: https://github.com/LuaJIT/LuaJIT/issues/1454.
 local test = tap.test('lj-1454-os-time')
 


+-- See also: https://github.com/LuaJIT/LuaJIT/issues/1454.
+local test = tap.test('lj-1454-os-time')
I prefer the lj-1454-ub-os-time name (as you named the branch). Feel
free to ignore.

Updated:

 -- See also: https://github.com/LuaJIT/LuaJIT/issues/1454.
-local test = tap.test('lj-1454-os-time')
+local test = tap.test('lj-1454-ub-os-time')
 
 test:plan(1)


+
+test:plan(1)
+
+local INT_MIN = -2 ^ 31
+
+local cur_time = os.time({
+  day = 1,
+  month = INT_MIN,
+  year = INT_MIN,
+})
+test:is(cur_time, nil, 'os.time() with INT_MIN')
+
+test:done(true)
-- 
2.43.0


    
--------------Su2YvJ3IHXD4msQ0z0WLGcLM--