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 E4A275C1DA8; Mon, 28 Aug 2023 17:02:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E4A275C1DA8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1693231328; bh=3aupvIl2XtGGMoZO1LmhvIxPDTlmo3213Mmi6ycl89M=; 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=d0BxmnULu2fo/tHElUfyal38ed3v3YO/qA2LFzM2pYaJC3R+8lOh0EBolspZ5cCH0 M06HEiV6NBbXGZM5w9mmFThbnJcFsodOb4QlxjasWrJzFw9myNKlRAKqxII0z+oQBm 7k68QAgHr852kcsrnob6MvqCarZeWgqgaVgtzJe4= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 5A2725BE742 for ; Mon, 28 Aug 2023 17:02:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5A2725BE742 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1qacog-0000qa-HA; Mon, 28 Aug 2023 17:02:06 +0300 Message-ID: Date: Mon, 28 Aug 2023 17:02:06 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <20230824100233.25009-1-skaplun@tarantool.org> In-Reply-To: <20230824100233.25009-1-skaplun@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD96201AD55A1C8F7DB61D29A291ECBF3870B600DAE42344AB9182A05F5380850404C228DA9ACA6FE27B789A2EAAC8C0D6650A4A235393F7082672CA3B577C39F94E10117B0395423A2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE741DC22BF90A736D8EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637968EC5F77C2942FE8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8312865D86112E9FBEBF607EB043BFBF9117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC9ECA4966ACB4B5DBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE33AC447995A7AD181150BA43C84913FC3A03B725D353964B062BEEFFB5F8EA3E35872C767BF85DA227C277FBC8AE2E8B80B9CEB5436E71E375ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A5E89EDA92DA4BAC627944BADF9DABA0D369236B9C8640BD4CF87CCE6106E1FC07E67D4AC08A07B9B0CE135D2742255B35CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF90E20E5A55B1E4AE3472FA7FA4ECD72DE0C3113608B91B25DD6C3C50D530F3B01F5011C79ABBA8E75088795BE9012648C3FB91E28C951159497F5A5A42147CF8E48CAC7CA610320002C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojrC6BcuK2ROw18olhFUdzaA== X-DA7885C5: 6828A51687F9F10F8182A9DCFC22852A4FF826830E22E91F79F1A07DC2ABCF5B262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73930F533AC2B33E986BAAD6DF07D3C2F0EF3B48DFEF8679D8EEDD788429FD8613638ED9BB8B05EE7B3AFB559BB5D741EB96D19CD4E7312BAA970A04DAD6CC59E3365FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Fix binary number literal parsing. 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" Sergey, thanks for the patch! LGTM. Sergey On 8/24/23 13:02, Sergey Kaplun wrote: > From: Mike Pall > > Reported by Egor Skriptunoff. > > (cherry-picked from commit 377a8488b62a9f1b589bb68875dd1288aa70e76e) > > Binary number with fractional part is invalid. Parsing of such binary > numbers returns `STRSCAN_ERROR` for any numbers with non-zero fractional > part, because it gives non-zero power of the exponent (`ex2`) in > `strscan_bin()`. But binary numbers with a zero fractional part > considered as valid numbers. To avoid such inconsistency the check, that > the given base doesn't equal 2, is added, when parsing decimal point > part of the literal. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#8825 > --- > > Branch: https://github.com/tarantool/luajit/tree/skaplun/fix-binary-number-parsing > Issue: https://github.com/tarantool/tarantool/issues/8825 > ML: https://www.freelists.org/post/luajit/Fractional-binary-number-literals > Tarantool PR: https://github.com/tarantool/tarantool/pull/9028 > > Tarantool's CI is red, because static build on aarch64 can't fetch the > LuaJIT's submodule commit somehow. Looks unrelated to the commit:). > > src/lj_strscan.c | 1 + > .../fix-binary-number-parsing.test.lua | 17 +++++++++++++++++ > 2 files changed, 18 insertions(+) > create mode 100644 test/tarantool-tests/fix-binary-number-parsing.test.lua > > diff --git a/src/lj_strscan.c b/src/lj_strscan.c > index 11d341ee..a2d92714 100644 > --- a/src/lj_strscan.c > +++ b/src/lj_strscan.c > @@ -444,6 +444,7 @@ StrScanFmt lj_strscan_scan(const uint8_t *p, MSize len, TValue *o, > > /* Handle decimal point. */ > if (dp) { > + if (base == 2) return STRSCAN_ERROR; > fmt = STRSCAN_NUM; > if (dig) { > ex = (int32_t)(dp-(p-1)); dp = p-1; > diff --git a/test/tarantool-tests/fix-binary-number-parsing.test.lua b/test/tarantool-tests/fix-binary-number-parsing.test.lua > new file mode 100644 > index 00000000..df82bd0b > --- /dev/null > +++ b/test/tarantool-tests/fix-binary-number-parsing.test.lua > @@ -0,0 +1,17 @@ > +local tap = require('tap') > + > +-- Test file to demonstrate incorrect behaviour of binary number > +-- parsing with fractional dot. > +-- See also: > +-- https://www.freelists.org/post/luajit/Fractional-binary-number-literals > +local test = tap.test('fix-binary-number-parsing') > +test:plan(2) > + > +-- Test that incorrect literal with non-0 fractional part still > +-- can't be converted to number. > +test:is(tonumber('0b.1'), nil, '0b.1 is not converted') > +-- Test that incorrect literal with 0 fractional part can't be > +-- converted to number. > +test:is(tonumber('0b.0'), nil, '0b.0 is not converted') > + > +test:done(true)