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 E0747CDFC8F; Tue, 17 Sep 2024 09:33:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E0747CDFC8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1726554789; bh=X3H9ciGVWxorVfEom9vKFmzaniGSnHJM4hOKYWtgrx4=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=foREY+cSl/7VQv6gAbr1SE6JIJlzpXQgQRNmhlWF3pj8Apo9lSHDwSciK9/Nd86WD 2Pb8MKTgxkzkr9kSEJs+vq0IoZ9lMKwu2hwK/mY5uQvzueigXlw14CbZXIKsIOycOZ 8jm8QvKDAaNbpmTr0kM28LYMC9lcp1lKsYv9CCmM= Received: from smtp3.i.mail.ru (smtp3.i.mail.ru [95.163.41.67]) (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 0368ECDFC82 for ; Tue, 17 Sep 2024 09:33:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0368ECDFC82 Received: by smtp3.i.mail.ru with esmtpa (envelope-from ) id 1sqRlr-00000008KWm-0gBx; Tue, 17 Sep 2024 09:33:07 +0300 Content-Type: multipart/alternative; boundary="------------coM3N0nUw7Ig624I00hfKevf" Message-ID: Date: Tue, 17 Sep 2024 09:33:06 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , tarantool-patches@dev.tarantool.org References: <20240821082316.4880-1-skaplun@tarantool.org> <695c49d0-f2f0-4cfb-b5d3-e4ac52d1f455@tarantool.org> In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD921D24E727BB09B71DC5817035459B2FAD17D50447E197F0B182A05F538085040F508AB2BEC72AF07C7A4B249DE6549FDEE818079A81F991308B718F93C6351FAC1B496903CC57CC2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7BBC4AF2A01A27A06EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B35447D73BF3EFFE8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D80E42D27A2933528AAFAFEFE5E95154E4FE180EA262B9DADCCC7F00164DA146DAFE8445B8C89999728AA50765F790063783E00425F71A4181389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8ED96AA85C75E140D117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CFA3FB0D9844EF8EC576E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8BC2ED6D5310B1F811D81D268191BDAD3D3666184CF4C3C14F3FC91FA280E0CE3D1A620F70A64A45A98AA50765F7900637AC4ECE65C2AF15826D1867E19FE1407978DA827A17800CE705056152E029236E2DBA43225CD8A89FD2A95C73FD1EFF45C6EABA9B74D0DA47B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A55D6A3A9A76B7A1645002B1117B3ED696594EED7E379ACCFB4A0A47EBA01A636A823CB91A9FED034534781492E4B8EEAD9CFA8CFAC159CE19BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF4416488CA77DB1B7B6C6EA208AFDE4F0A3FE72766B860BE4404C42168E57CE683B77A83432DF81E46C89B7A10C2A3D35D585C7A6D1EA671BC8E706061C9CA382C68479F857741459111DC66A97D0BFE2913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojK9mC3H63xFbufUFEXXaW9w== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140767C0FFFF42C88C6DCA9057F3E010A393A4D3DE37CAEA49F0152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Restore state when recording __concat metamethod throws an error. 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" This is a multi-part message in MIME format. --------------coM3N0nUw7Ig624I00hfKevf Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey, thanks for fixes! LGTM On 13.09.2024 18:48, Sergey Kaplun wrote: > One more minor update below. > > On 13.09.24, Sergey Kaplun via Tarantool-patches wrote: >> Hi, Sergey! >> Thanks for the review! >> >> On 13.09.24, Sergey Bronnikov wrote: >>> Hi, Sergey, >>> >>> thanks for the patch! LGTM with a minor comment. See below. >>> >>> On 21.08.2024 11:23, Sergey Kaplun wrote: >>> >>> >>> >>> >>>> +-- Need to use metamethod call in the concat recording. >>>> +debug.setmetatable(nil, { >>> I propose to add a comment that explain why `nil` is used here. >> I've removed the nil usage to avoid confusion. >> Branch is rebased on the current master and force-pushed. >> =================================================================== >> diff --git a/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua b/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua >> index 9abaeba5..4fe02708 100644 >> --- a/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua >> +++ b/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua >> @@ -12,12 +12,13 @@ test:plan(2) >> >> jit.opt.start('hotloop=1') >> >> -local __concat = function(v1, v2) >> - return tostring(v1) .. tostring(v2) >> +local __concat = function() >> + return '' >> end >> >> -- Need to use metamethod call in the concat recording. >> -debug.setmetatable(nil, { >> +-- Let's use a table with the metamethod. >> +local concatable_t = setmetatable({}, { >> __concat = __concat, >> }) >> >> @@ -31,7 +32,7 @@ local function test_concat_p() >> -- `lj_record_ret()` restore the Lua stack (before the patch), >> -- it becomes unbalanced after the instruction recording >> -- attempt. >> - local _ = {} .. (nil .. nil) >> + local _ = {} .. (concatable_t .. concatable_t) >> end >> end >> >> =================================================================== > Added more verbose description: > > =================================================================== > diff --git a/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua b/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua > index 4fe02708..75736e74 100644 > --- a/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua > +++ b/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua > @@ -17,7 +17,8 @@ local __concat = function() > end > > -- Need to use metamethod call in the concat recording. > --- Let's use a table with the metamethod. > +-- We may use any object with a metamethod, but let's use a table > +-- as the most common one. > local concatable_t = setmetatable({}, { > __concat = __concat, > }) > =================================================================== > >>>> + __concat = __concat, >>>> +}) >>>> + >> >> >> -- >> Best regards, >> Sergey Kaplun --------------coM3N0nUw7Ig624I00hfKevf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey,

thanks for fixes! LGTM

On 13.09.2024 18:48, Sergey Kaplun wrote:
One more minor update below.

On 13.09.24, Sergey Kaplun via Tarantool-patches wrote:
Hi, Sergey!
Thanks for the review!

On 13.09.24, Sergey Bronnikov wrote:
Hi, Sergey,

thanks for the patch! LGTM with a minor comment. See below.

On 21.08.2024 11:23, Sergey Kaplun wrote:


<snipped>

+-- Need to use metamethod call in the concat recording.
+debug.setmetatable(nil, {
I propose to add a comment that explain why `nil` is used here.
I've removed the nil usage to avoid confusion.
Branch is rebased on the current master and force-pushed.
===================================================================
diff --git a/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua b/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua
index 9abaeba5..4fe02708 100644
--- a/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua
+++ b/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua
@@ -12,12 +12,13 @@ test:plan(2)
 
 jit.opt.start('hotloop=1')
 
-local __concat = function(v1, v2)
-    return tostring(v1) .. tostring(v2)
+local __concat = function()
+  return ''
 end
 
 -- Need to use metamethod call in the concat recording.
-debug.setmetatable(nil, {
+-- Let's use a table with the metamethod.
+local concatable_t = setmetatable({}, {
   __concat = __concat,
 })
 
@@ -31,7 +32,7 @@ local function test_concat_p()
     -- `lj_record_ret()` restore the Lua stack (before the patch),
     -- it becomes unbalanced after the instruction recording
     -- attempt.
-    local _ = {} .. (nil .. nil)
+    local _ = {} .. (concatable_t .. concatable_t)
   end
 end
 
===================================================================
Added more verbose description:

===================================================================
diff --git a/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua b/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua
index 4fe02708..75736e74 100644
--- a/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua
+++ b/test/tarantool-tests/lj-1234-err-in-record-concat.test.lua
@@ -17,7 +17,8 @@ local __concat = function()
 end
 
 -- Need to use metamethod call in the concat recording.
--- Let's use a table with the metamethod.
+-- We may use any object with a metamethod, but let's use a table
+-- as the most common one.
 local concatable_t = setmetatable({}, {
   __concat = __concat,
 })
===================================================================


        
+  __concat = __concat,
+})
+
<snipped>

-- 
Best regards,
Sergey Kaplun

    
--------------coM3N0nUw7Ig624I00hfKevf--