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 62CF59AD9EA; Thu, 25 Jan 2024 13:10:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 62CF59AD9EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1706177447; bh=w+adb63j/Z3abH/s1uV2q31VS7Us5IX/tZ5ziwPKmDQ=; 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=RhYyjfVlYpwVVrcju7BNjhBMFTnWue+kc4f+cfRMuDTGf3cxIPO0Y/mOxrdz6cSjz 9mDPBr2yHC+FibZa9vR/KU9aUWRvTG2nJZ4CgRbXerO391/G5sGLlbpeaV1ayLqcgm vwbEH2tFoWixf8P+OvRtIBkkRSFX8FY/tAoBcLow= Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [95.163.41.100]) (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 7D3259AD9C0 for ; Thu, 25 Jan 2024 13:10:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7D3259AD9C0 Received: by smtp63.i.mail.ru with esmtpa (envelope-from ) id 1rSwh3-0090Ri-1L; Thu, 25 Jan 2024 13:10:45 +0300 Date: Thu, 25 Jan 2024 13:06:32 +0300 To: Sergey Bronnikov Message-ID: References: <20231121085253.13526-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD96A58C36AA2E99649EAAC3983AE61A60E39D54955C48233FF182A05F53808504082E54B2737CFB8C05C277D5D3C584350857F653EF793CE1AE4EBFDB2C42E9215 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70043D879A87EF1BCEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DA223B75F41C64628638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8BC5EE9758299DCCA57E0C61C77CDC174117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCA9BB761A57C26B8FA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352026055571C92BF10FE5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269176DF2183F8FC7C0FE3A47D6FA29121068655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CC1948A84299AD5C643847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A527BF10FBDB0A40F6B300A887B4820B08A5BB2383CD4DD81EF87CCE6106E1FC07E67D4AC08A07B9B017119E5299B287EECB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFCE806099CCBA2110C7F822ADD9B9C2FA85B31CF70B3D0A0B1BE91A21F9EFA0968926F27D50C27B5D4BEAD515961AA0A7FEB536FAF775288598C4276DB3E3405FE48CAC7CA610320002C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojjPo90oGNxwIdcxvOtxFbkQ== X-DA7885C5: 09FD88D59CF7C304C33E7729EE08BE70507D4276D01910D35CE3E9EA2B57A2CD262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F7393590D8C940224AE3356653C1272E032E69A227EF841CDE6000FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 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 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 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) -- Best regards, Sergey Kaplun