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 8BA4228D84B; Fri, 3 Feb 2023 11:35:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8BA4228D84B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1675413352; bh=hJqGXvOwD/Y7iQRYwNRUM02Jr6Ms/tvLdvc969bxWNA=; 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=iZbR7Dq+CNMhphQelrV/Ci/Y00aprjmnjvz6lvOyWPsFerfyznbq8HFQvfj5RI1SN wSCCalZI0OBzg5denb52rHMONEZssjVWZsDbWaAdtJP0FDoT//uKDarZ9+B0qcvv9T fzTi+K8PghmEZUrgrxwpvbsPn5x3LUQbncXUfHMI= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 46D2B6ECCC for ; Fri, 3 Feb 2023 11:35:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 46D2B6ECCC Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1pNrXy-00032U-CF; Fri, 03 Feb 2023 11:35:50 +0300 Date: Fri, 3 Feb 2023 11:32:22 +0300 To: sergos Message-ID: References: <20230201074651.8282-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9AD83B49AC1DDA08967EC36FA2B240E0E9DA1CCEB7D38F385182A05F5380850404C228DA9ACA6FE27739323A35CF18B7285BDCBD96C46385D9C3B4488594EE860687BA0C6633CE36A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72F22E6DC541F75D9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B84F9009663064BD8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8B78BC1C1B93A2360345FCD95F39F4EE3117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC60CDF180582EB8FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520C65AC60A1F0286FEE5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A45692FFBBD75A6A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D343C45ADCD169245FA3AAC1AC57D50E4E7843B13107CAEFF4574BEEE8528DA3E8C5884B7E3FC13BF1A1D7E09C32AA3244CFFFBC746CB570DDBBD0034F8F865E7D135DA7DC5AF9B58C0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojdzjlIIgnltYyN17bZtsKsA== X-DA7885C5: E68A03B952C941DA118E97D9348F50F706B395ECA3E4AF7CD5536A246322BF11262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73933AF1F914F131DBF5E14C4E05773789C781EF1021573031FE0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Fix os.date() for wider libc strftime() compatibility. 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, Sergos! Thanks for the review! Changed the test as you propose: =================================================================== diff --git a/test/tarantool-tests/lj-463-os-date-oom.test.lua b/test/tarantool-tests/lj-463-os-date-oom.test.lua index a39ab6d1..0861ce14 100644 --- a/test/tarantool-tests/lj-463-os-date-oom.test.lua +++ b/test/tarantool-tests/lj-463-os-date-oom.test.lua @@ -4,15 +4,13 @@ local tap = require('tap') local test = tap.test('lj-463-os-date-oom') test:plan(1) --- The ru_RU.utf8 locale is chosen as one that will be set on a --- developer's PC with a high possibility. It may be unavailable --- at CI, so don't check the status and result of function calls. --- If it's unavailable `os.setlocale()` does nothing. +-- Try all available locales to check the behaviour. -- Before the patch, the call to `os.date('%p')` on non-standard --- locale may lead to OOM. - -os.setlocale('ru_RU.utf8') -os.date('%p') +-- locale (ru_RU.utf8, sv_SE.utf8, etc.) may lead to OOM. +for locale in io.popen('locale -a'):read('*a'):gmatch('([^\n]*)\n?') do + os.setlocale(locale) + os.date('%p') +end test:ok(true, 'os.date() finished without OOM') =================================================================== Branch is force-pushed. On 03.02.23, sergos wrote: > Hi! > > Thanks for the patch! > > I can propose to update test with something like > > for i in io.popen('locale -a', 'r'):read('*a'):gmatch("([^\n]*)\n?") do > os.setlocale(i) > os.date(%p) > end > > to run the test across all available options. The reason is I got: > > tarantool> os.setlocale('ru_RU.utf8') > --- > - null > > on my system, so I don’t by the ‘high probability’. Lucky you:). > > Regards, > Sergos > > > > On 1 Feb 2023, at 10:46, Sergey Kaplun wrote: > > > > From: Mike Pall > > > > Thanks to Jesper Lundgren. > > > > (cherry picked from commit fc63c938b522e147ea728b75f385728bf4a8fc35) > > > > When `strftime()` returns empty result (for example, for "%p" on some > > locales or when LuaJIT is built with musl's `strftime()` and format > > string is invalid), the `os.date()` endless retries to format result > > and reallocates buffer for resulting string. This leads to OOM. > > > > This patch limits amount of retries by 4. > > > > Sergey Kaplun: > > * added the description and the test for the problem > > > > Part of tarantool/tarantool#8069 > > --- > > > > PR: https://github.com/tarantool/tarantool/pull/8237 > > Issues: > > * https://github.com/LuaJIT/LuaJIT/issues/463 > > * https://github.com/tarantool/tarantool/issues/8069 > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-463-os-date-oom-full-ci > > > > src/lib_os.c | 4 ++-- > > .../lj-463-os-date-oom.test.lua | 19 +++++++++++++++++++ > > 2 files changed, 21 insertions(+), 2 deletions(-) > > create mode 100644 test/tarantool-tests/lj-463-os-date-oom.test.lua > > > > diff --git a/src/lib_os.c b/src/lib_os.c > > index 9e78d49a..ffbc3fdc 100644 > > --- a/src/lib_os.c > > +++ b/src/lib_os.c > > diff --git a/test/tarantool-tests/lj-463-os-date-oom.test.lua b/test/tarantool-tests/lj-463-os-date-oom.test.lua > > new file mode 100644 > > index 00000000..cce78b6e > > --- /dev/null > > +++ b/test/tarantool-tests/lj-463-os-date-oom.test.lua > > @@ -0,0 +1,19 @@ > > +local tap = require('tap') > > + > > +-- See also https://github.com/LuaJIT/LuaJIT/issues/463. > > +local test = tap.test('lj-463-os-date-oom') > > +test:plan(1) > > + > > +-- The ru_RU.utf8 locale is chosen as one that will be set on a > > +-- developer's PC with high possibility. It may be unavailable at > > +-- CI, so don't check the status and result of function calls. > > +-- If it's unavailable `os.setlocale()` does nothing. > > +-- Before the patch, the call to `os.date('%p')` on non-standard > > +-- locale may lead to OOM. > > + > > +os.setlocale('ru_RU.utf8') > > +os.date('%p') > > + > > +test:ok(true, 'os.date() finished without OOM') > > + > > +os.exit(test:check() and 0 or 1) > > -- > > 2.34.1 > > > -- Best regards, Sergey Kaplun