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 02DCA6F3D0; Tue, 31 Aug 2021 00:32:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 02DCA6F3D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1630359138; bh=Z9Ri4tcfr18dN4VL1mDwuD2DLnPdrHkbLuk5Kt1hj54=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=KDsrQkRJHp+k+ciVDGa+Hi5ppkyUfkpAFg5m0xqDjwrgr/iUMyBEy8/b9auiTphqN HPfHC3gfH/gyu9TGDLLs3MiG7HZ3cTrmaAYrV7bdIm1ftIYWvKkqo3UJ1ag7ZrGx+e CSJJsPQEJxWFPYqPFOajQ1ZqS7Ua8amElIndS/tU= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [94.100.179.3]) (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 D1A656F3C9 for ; Tue, 31 Aug 2021 00:32:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D1A656F3C9 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1mKot6-0008NL-1Z; Tue, 31 Aug 2021 00:32:16 +0300 To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org References: <7c4620245d61624883115541490cd94d10626c00.1629976113.git.imeevma@gmail.com> <40a89d61-e252-731c-d419-6c162eecefb4@tarantool.org> <20210827152223.GA435770@tarantool.org> <491db4a6-2fa4-8346-c22f-0924630f7e55@tarantool.org> <20210830055706.GA63349@tarantool.org> Message-ID: Date: Mon, 30 Aug 2021 23:32:15 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210830055706.GA63349@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9736CF3E71F18CE0C3E1D5927724F4AAA182A05F53808504034E54650B893ACA22A157268B8E9871C98EEC40D33A9A3A25B22977548E9D9FD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79145AB6E9E75F07EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637ED2BA022FBF94AB68638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D89C7ED1445721B14DF20FB6DF923AD9C0117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD1828451B159A507268D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B65D56369A3576CBA5089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505952DBA56822D4FCF65729AD230EA6CE4 X-C1DE0DAB: 0D63561A33F958A5F5E0A7E95E3F985213C988810E329293EB9DCF1FEE257F2BD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA752546FE575EB473F1410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3429499E429979B7C7C3EE07BF4AE712B47E1929E504D723A238B163A8001476D1F023C6B4DD0ACA0D1D7E09C32AA3244C19F30E98765BA9F043C574AAF0E4520663871F383B54D9B3729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj4DnN7V8kJ6sWcdbolEQrmg== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D2651F56B6E2B30CCA4D8DE48D6DA58AF3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 1/1] sql: fix error on copy empty string in mem_copy() 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the fixes! On 30.08.2021 07:57, Mergen Imeev wrote: > Thank you for the review! My answers, diff and new patch below. > > On Fri, Aug 27, 2021 at 11:44:23PM +0200, Vladislav Shpilevoy wrote: >> Thanks for the fixes! >> >> See 3 comments below. >> >>> sql: fix error on copy empty string in mem_copy() >>> >>> This patch fixes the problem with copying an empty string in mem_copy(). >>> Previously, because the string length was 0, an error was thrown, but >>> the diag was not set, which could lead to an error due to an empty diag >>> or to a double free. >>> >>> Closes #6157 >> >> 1. You also need to add closes 6399, don't you? >> > True, thank you. Fixed. You didn't add it to the changelog. You can use the same file for both tickets I think. >>> diff --git a/test/sql-tap/gh-6157-unnecessary-free-on-string.test.lua b/test/sql-tap/gh-6157-unnecessary-free-on-string.test.lua >>> new file mode 100755 >>> index 000000000..e0c09a325 >>> --- /dev/null >>> +++ b/test/sql-tap/gh-6157-unnecessary-free-on-string.test.lua >>> @@ -0,0 +1,18 @@ >>> +#!/usr/bin/env tarantool >>> +local tap = require('tap') >>> +local test = tap.test('test wrong error in mem_copy()') >>> + >>> +-- >>> +-- Make sure there is no assert due to an incorrectly set error in mem_copy(). >>> +-- How this test works: We have 128 mempool cells in SQL ("lookaside"), and >>> +-- until those 128 cells are filled in, the error cannot be reproduced. Also, we >>> +-- have to get '' from somewhere because if we just enter it, it will be of type >>> +-- STATIC and no memory will be allocated. >> >> 3. You mention 128 cells, but I don't see how 128 or something close is used >> in this test. >> > Fixed. Increased number of expressions to 129 and reworked the test-file a bit. If you say it depends on 128, why did the test fail without the patch even before you made it use 129 cells? > diff --git a/test/sql-tap/gh-6157-unnecessary-free-on-string.test.lua b/test/sql-tap/gh-6157-unnecessary-free-on-string.test.lua > new file mode 100755 > index 000000000..e2d25d7d4 > --- /dev/null > +++ b/test/sql-tap/gh-6157-unnecessary-free-on-string.test.lua > @@ -0,0 +1,29 @@ > +#!/usr/bin/env tarantool > +local test = require("sqltester") > +test:plan(1) > + > +-- > +-- Make sure there is no assert due to an incorrectly set error in mem_copy(). > +-- How this test works: We have 128 mempool cells in SQL ("lookaside"), and > +-- until those 128 cells are filled in, the error cannot be reproduced. Also, we > +-- have to get '' from somewhere because if we just enter it, it will be of type > +-- STATIC and no memory will be allocated. > +-- > +local s = "NULLIF(SUBSTR('123', 1, 0), NULL)" > +for i = 1, 7 do s = s..', '..s end > +s = "SELECT "..s..', '.."NULLIF(SUBSTR('123', 1, 0), NULL)" > +-- The "s" variable contains 129 expressions. > + > +test:do_execsql_test( > + "gh-6157", s, { > + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", > + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", > + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", > + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", > + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", > + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", > + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", > + "", "", "" Lua has loops. You can use them to avoid copy-paste. t = {} for i = 1, 129 do table.insert(t, '') end