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 395529DCFED; Thu, 25 Jan 2024 19:31:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 395529DCFED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1706200272; bh=8SqpaE3q+cL5BFATHpgxzAR8LC7qCASwIWS7BNiUQnM=; 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=ucnovXhyPF1VIQjxWR8NzDiU3q3mX0cwDr1lLU3YQ3NsH+0pCmTMZ/UOn3LKxOOCi PoNW57fSjSEvXHn9/vW/zR8mCiX0uck3fiQ5gZ/t+o/LX58t50/F4bF4oDJhMKwqv4 meSTToDaOzIkTJBs+V15T5dfaiZi/C7EBNd4ZjQ0= Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [95.163.41.92]) (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 B028F576490 for ; Thu, 25 Jan 2024 19:31:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B028F576490 Received: by smtp50.i.mail.ru with esmtpa (envelope-from ) id 1rT2dB-007k41-2M; Thu, 25 Jan 2024 19:31:10 +0300 Message-ID: <6c5cfdc0-410c-4bf1-bc1d-f895d4ef3519@tarantool.org> Date: Thu, 25 Jan 2024 19:31:09 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun References: <20231121085253.13526-1-skaplun@tarantool.org> Content-Language: en-US In-Reply-To: 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: 4F1203BC0FB41BD9260BB214B72A237723050DA0F9CEC155EA46ABB1F3CB6081182A05F5380850404C228DA9ACA6FE27AFF36F861E142655BCE0B469769027D376D1DD06D5A45445DE39DDA8C848E646 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C6068CE86C2B75F5EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FD85A7F5EB0E97528638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D814130C63BD1ED05525264D020F7FA39A117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC049C5FA07E1E73E1A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520B1593CA6EC85F86D618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE140C956E756FBB7A4AAC223A686B1DECD8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE313BDA61BF53F5E1D2D242C3BD2E3F4C6C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947C062BEEFFB5F8EA3E2E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F9FFED5BD9FB4175535872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A5759B20F2D9644BA3CAE71B0D7FD5A34CB1F81E620164DE40F87CCE6106E1FC07E67D4AC08A07B9B097AD43380FEE24CACB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFBC2C684B2BEE39B11584303E40EE8BA0C62F21FC59AF8E9537C57C9E234F7E0AE4A5F4FEF661E8B5BE544D9C67035674EFAD5B7D1A9ED1B8B64C9A5CFF7F5C13E48CAC7CA610320002C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojuMLZpRPFtSzshxlR7ox9FQ== X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F2588458BE520364644BB0CCA8C38D194A3B04F8273299E982988C7F282EC151BADDC1D3523A6D01B4765B2DFB59E2DDD9FE06B14FA522850F29BC30B0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Limit exponent range in number 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 Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks! LGTM now On 1/25/24 13:06, Sergey Kaplun wrote: > Hi, Sergey! > Thanks for the review! > > Fixed you comment, see the patch below. > Branch is force-pushed. > > On 25.01.24, Sergey Bronnikov wrote: >> Hi, Sergey! >> >> thanks for the patch! >> >> >> On 1/24/24 00:14, Sergey Kaplun wrote: >> >> >> >> >>> +++ b/test/tarantool-tests/lj-788-limit-exponents-range.test.lua >>> @@ -0,0 +1,29 @@ >>> +local tap = require('tap') >>> + >>> +-- Test file to demonstrate incorrect behaviour of exponent number >>> +-- form parsing. >>> +-- See also: https://github.com/LuaJIT/LuaJIT/issues/788. >>> +local test = tap.test('lj-788-limit-exponents-range') >>> +test:plan(2) >>> + >>> +-- Before the patch, the powers greater than (1 << 16) * 10 >>> +-- (655360) were parsed incorrectly. After the patch, powers >>> +-- greater than 1 << 20 (1048576 `STRSCAN_MAXEXP`) are considered >>> +-- invalid. See for details. >>> +-- Choose the first value between these values and the second >>> +-- value bigger than `STRSCAN_MAXEXP` to check parsing correctness >> typical values on testing boundaries [1] are: value before the boundary, >> >> boundary value and value after the boundary. So I propose to test these >> three values. >> >> 1: https://en.wikipedia.org/wiki/Boundary-value_analysis > Thanks! Good to know:). > > I added the boundary test case and updated tests names as you suggested. > > =================================================================== > diff --git a/test/tarantool-tests/lj-788-limit-exponents-range.test.lua b/test/tarantool-tests/lj-788-limit-exponents-range.test.lua > index 8ab31600..0af584fd 100644 > --- a/test/tarantool-tests/lj-788-limit-exponents-range.test.lua > +++ b/test/tarantool-tests/lj-788-limit-exponents-range.test.lua > @@ -4,7 +4,7 @@ local tap = require('tap') > -- form parsing. > -- See also: https://github.com/LuaJIT/LuaJIT/issues/788. > local test = tap.test('lj-788-limit-exponents-range') > -test:plan(2) > +test:plan(3) > > -- Before the patch, the powers greater than (1 << 16) * 10 > -- (655360) were parsed incorrectly. After the patch, powers > @@ -14,6 +14,7 @@ test:plan(2) > -- value bigger than `STRSCAN_MAXEXP` to check parsing correctness > -- for the first one, and `STRSCAN_ERROR` for the second case. > local PARSABLE_EXP_POWER = 1000000 > +local STRSCAN_MAXEXP = 1048576 > local TOO_LARGE_EXP_POWER = 1050000 > > local function form_exp_string(n) > @@ -21,9 +22,12 @@ local function form_exp_string(n) > end > > test:is(tonumber(form_exp_string(PARSABLE_EXP_POWER)), 1, > - 'correct parsing of large exponent') > + 'correct parsing of large exponent before the boundary') > + > +test:is(tonumber(form_exp_string(STRSCAN_MAXEXP)), nil, > + 'boundary power of exponent is not parsed') > > test:is(tonumber(form_exp_string(TOO_LARGE_EXP_POWER)), nil, > - 'too big exponent power is not parsed') > + 'too big exponent power after the boundary is not parsed') > > test:done(true) > =================================================================== > >>> +-- for the first one, and `STRSCAN_ERROR` for the second case. >>> +local PARSABLE_EXP_POWER = 1000000 >>> +local TOO_LARGE_EXP_POWER = 1050000 >>> + >>> +local function form_exp_string(n) >>> + return '0.' .. string.rep('0', n - 1) .. '1e' .. tostring(n) >>> +end >>> + >>> +test:is(tonumber(form_exp_string(PARSABLE_EXP_POWER)), 1, >>> + 'correct parsing of large exponent') >>> + >>> +test:is(tonumber(form_exp_string(TOO_LARGE_EXP_POWER)), nil, >>> + 'too big exponent power is not parsed') >>> + >>> +test:done(true)