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 081B56ECCC; Sat, 6 Jun 2026 10:15:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 081B56ECCC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1780730114; bh=2J2zXZtbq2VRGDFSyJy7D9QjmhRxhmHbBjnaogsamcw=; 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=qw4SC1Y26SysyLcmNGwjUsH7yxOGNPUI70SZF3rl4w96uziZxlSJRCFyJWfV6cDpM 2du31M5PKvziNTKVRtc0aqjjC2EwREMOeP611N/xWZ/dvc/qCexI3SrshhvRl8WHsc hKHXnLXAbY/zmDN7vqbZNdXXSbckBrJTQAj6rDfY= Received: from send103.i.mail.ru (send103.i.mail.ru [89.221.237.198]) (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 9D5256ECCC for ; Sat, 6 Jun 2026 10:15:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9D5256ECCC Received: by exim-smtp-85dd497b6-ltwt2 with esmtpa (envelope-from ) id 1wVlFP-00000000MvI-2Sim; Sat, 06 Jun 2026 10:15:11 +0300 Date: Sat, 6 Jun 2026 10:14:36 +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-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9421AE2B81725B364D9FF979D7F4575BA23CAF6170A8DFAC71313CFAB8367EF908E2BE116634AD74D8FFF8536B9FA640DEAE04967732FC4583DC2AF795D076B9970AC76DA7C098EE25F9067195EC86057 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FEAC828D2BF6EC3CEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB5533756660A56BB7F6F20B6012B83FE4B9B808430FF5FAD7A5358E9AD629B7672D3BED61389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0A29E2F051442AF778941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6F459A8243F1D1D44CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE76D0F27F7E6A6C418731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5238AB7B90C652B3C5002B1117B3ED696199AFBCAD76CAA0733EE06AFCD9648883610D81D389A125CDE35189EBF2DEA28FEA14CD2CD220BB99C5DF10A05D560A9880EC71AF561E0AAD9143641EC25BB39489D81305FB9AC8D X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F9677DD89D51EBB774225B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6599A69C603D5A7C845BF91308AF57686B0F86054B391C46F532C0AB28E4519F1B4F25BB5AC8DDDBECEB8341EE9D5BE9A0A9BB4983EBE4A192EF7DA64DFA536D10D3FA4F5BFAD50CF086536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVRI2994ruhLUqnUDF+evyps= X-DA7885C5: F3017E44523F782CF255D290C0D534F9C80C52CA9C4E4CE40C4DAFD627F2104B04EF2189C05556D05B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393520AF17B8A65FDE2C73970E27BEAF7C4DFA6B461AC9AD07CE9950B6EADC42083E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F 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 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, 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/ > `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. > > 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. > @@ -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/ > +-- 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. > + > +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 > -- Best regards, Sergey Kaplun