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 9E8776EC11B; Thu, 23 Nov 2023 09:38:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9E8776EC11B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1700721527; bh=gXQ9kmIu5ZbBTlXTGBB4h/p2DM2+jm/oA/odj6uumo0=; 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=StpxJuzmp1RBNf31BOIuIyuTkRWKaBD3/FE5ZXFXgGVHTnLwUmCRpqIr1qEkfqiDV kDpnA7SJrdstBJ6eI+/23clYu+jNwoXdArDpCmXsl1YfAHXDQRik67EGHCBx7FJxfj K+E5tldbAVklDd3OKN8nSixSNOrIbZrWqPmv+sec= Received: from smtp41.i.mail.ru (smtp41.i.mail.ru [95.163.41.64]) (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 970366EC10A for ; Thu, 23 Nov 2023 09:36:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 970366EC10A Received: by smtp41.i.mail.ru with esmtpa (envelope-from ) id 1r63Jw-00ETQs-2k; Thu, 23 Nov 2023 09:36:17 +0300 Date: Thu, 23 Nov 2023 06:31:52 +0000 To: Sergey Bronnikov Message-ID: References: <26636e3dcb8ade3bdc23d9544f9a7e2ffe4322b2.1695711374.git.sergeyb@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <26636e3dcb8ade3bdc23d9544f9a7e2ffe4322b2.1695711374.git.sergeyb@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9FEA8E122FE2215F5F9A7F26A9461D4801668790ACF3513421867C24CE74E72BB5FE18E9CBFBE7C077C0A30122E2FBA2B7E6807EAB1CDAE6C27BE07829BF85B2EFA673BDF079014B0 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72F22E6DC541F75D9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006371ECA800C705ED7E68638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CA476DF8D15A08AF626F53B768E71CAB117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCE2CCD8F0CAA010FB389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC817119E5299B287EEF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CF8BD4E506CFA3D882D242C3BD2E3F4C64AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3856009BA58C5E1BBBA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CFCF36E64A7E3F8E581DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C39D7D3120FB43BDE335872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A5F66AEFB9A543175E45B44ACA47F7BBDF7ECCF1D4C929BCE6F87CCE6106E1FC07E67D4AC08A07B9B04E7D9683544204AFCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D342E8FEDBD32DECB6DD6D8F0D5C0D6008FF0C0DAB2AB3ECDA6D0D9AB4497C3FB6CCD563006F0C30EE41D7E09C32AA3244C79EEF0C65CF31C6423221971784A8DD9259227199D06760ABAD658CF5C8AB4025DA084F8E80FEBD376A4ED3E9341DC2FCD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojOz05VK5QHNqtcXQ3fCVE0w== X-Mailru-Sender: 2FEBA92C8E508479FE7B9A1DF348D5311A0CF5E08F56F5DAC95AB1372D03E156273588BA88E190882326FE6F2A341ACE0FB9F97486540B4CD9E8847AB8CFED4D9ABF8A61C016C2CFB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] LJ_GC64: Fix lua_concat(). 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: max.kokryashkin@gmail.com, tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, I've checked the patchset into all long-term branches in tarantool/luajit and bumped a new version in master, release/2.11 and release/2.10. On 26.09.23, Sergey Bronnikov via Tarantool-patches wrote: > From: Sergey Bronnikov > > Reported by Mathias Westerdahl. > > (cherry picked from commit 633f265f67f322cbe2c5fd11d3e46d968ac220f7) > > Lua 5.1 Reference Manual [1] defines a function `lua_concat`, that: > > > void lua_concat (lua_State *L, int n); > > > > Concatenates the n values at the top of the stack, pops them, and leaves > > the result at the top. > > Without the patch `lua_concat()` behaved incorrectly with userdata with > defined `__concat` metamethod. The problem is GC64-specific. > > Assuming we have three literals and a userdata with defined "__concat" > metamethod on top of the Lua stack: > > 1 [string] > 2 [string] > 3 [string] > 4 [string] > 5 [userdata] <--- top > > On attempt to concatenate *two* items on top Lua stack, `lua_concat()` > concatenates *four* items and leaves result at the top: > > 1 [string] > 2 [string][string][string][userdata] <--- top > > The problem is in incorrect calculation of `n` counter in a loop in > implementation of function `lua_concat`. Without a fix `n` is equal to 3 > at the end of the first iteration and therefore it goes to the next > iteration of concatenation. In a fixed implementation of `lua_concat()` > `n` is equal to 1 at the end of the first loop iteration, decremented in > a loop postcondition and breaks a loop. > > The patch fixes incorrect behaviour. > > 1. https://www.lua.org/manual/5.1/manual.html > > Sergey Bronnikov: > * added the description and the test for the problem > > Part of tarantool/tarantool#8825 > --- > PR: https://github.com/tarantool/tarantool/pull/9176 > Branch: https://github.com/tarantool/luajit/commits/ligurio/lj-881-fix-concat > Issues: > - https://github.com/LuaJIT/LuaJIT/issues/881 > - https://github.com/tarantool/tarantool/issues/8825 > > src/lj_api.c | 2 +- > .../lj-881-fix-lua-concat.test.c | 116 ++++++++++++++++++ > 2 files changed, 117 insertions(+), 1 deletion(-) > create mode 100644 test/tarantool-c-tests/lj-881-fix-lua-concat.test.c > > -- > 2.34.1 > -- Best regards, IM