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 723BC6F1841; Wed, 29 Nov 2023 17:39:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 723BC6F1841 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1701268767; bh=KiQFOvNG9YGN5kqkl8ke1EJl6byjyeqs01FTLCsbnbk=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=MPoziBAa+RlaOShwPP3uMJqx3mF+MSFnMSXvKHHWIv6w46sIIlca8U+cR8pffohKu y2rsG2ZVIn20DBrECfgC9puVcsN6nit+GqP1ZrTK74eJa/h8jp5jNRSytzTUNMSTvr njpCgbRB99dO7DcyPk72NIxDoVi7oFTzdr+GpHCg= Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [95.163.41.76]) (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 8593C6F1841 for ; Wed, 29 Nov 2023 17:39:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8593C6F1841 Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1r8Lin-0014w0-21; Wed, 29 Nov 2023 17:39:25 +0300 Message-ID: Date: Wed, 29 Nov 2023 17:39:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <30f685beb2bf4ce39dd82ede7b10c821af5c6f0d.1698049570.git.skaplun@tarantool.org> In-Reply-To: <30f685beb2bf4ce39dd82ede7b10c821af5c6f0d.1698049570.git.skaplun@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D2A6479154BC7F418A5726D9682ECCAA7CCFA245F45915FF182A05F5380850401BD7A77BDB7095369BE9949236E95E7143538B382D24A6F6C8EDE7FFC371EDBF X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70C5E0F71D77D667BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637578F58D66D7052C48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8520FFE1D0E541E740BECF322B9E50174117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF80095D1E57F4578A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18E5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE9647ADFADE5905B19100238FE36DC7A2D8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3632EDEA9CD5989A36136E347CC761E07C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CD2DCF9CF1F528DBC2E808ACE2090B5E1725E5C173C3A84C317B107DEF921CE79089D37D7C0E48F6C8AA50765F7900637F0A05763E19AB7F2EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A55BECADF3634A0C266B77985F266F81919BB1E11B2305983AF87CCE6106E1FC07E67D4AC08A07B9B01DAA61796BF5227BCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFAC5DE4696CFEAC55B49C60C7008A19EFC349B15311569E30E5D395CD160AA31A3D4CAFFB26F46A3D153AE024B6FD0844CA65290F68450FB2B28F43CBAA5EADE2E48CAC7CA610320002C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojxXIty/pLbajzLrSAjkDzyA== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769347BE80DC7C8177B9BE9949236E95E71BC4EE72AB2E748C5EBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/6] FFI: Fix missing cts->L initialization in argv2ctype(). 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" Hello, Sergey thanks for the patch! LGTM On 10/23/23 12:22, Sergey Kaplun wrote: > From: Mike Pall > > (cherry-picked from commit 50d6883e6027c4c2f9a5e495fee6b7fff1bd73c9) > > When start trace recording without an initialized `L` in CType State > (possible if the recording is started before any `ffi` library usage), > the corresponding assertion fails in the `lj_ctype_intern()`. This patch > adds missing initialization during recording. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#9145 > --- > src/lj_crecord.c | 2 +- > .../fix-argv2ctype-cts-L-init.test.lua | 15 +++++++++++++++ > .../fix-argv2ctype-cts-L-init/script.lua | 14 ++++++++++++++ > 3 files changed, 30 insertions(+), 1 deletion(-) > create mode 100644 test/tarantool-tests/fix-argv2ctype-cts-L-init.test.lua > create mode 100644 test/tarantool-tests/fix-argv2ctype-cts-L-init/script.lua > > diff --git a/src/lj_crecord.c b/src/lj_crecord.c > index e1d1110f..10d1dc70 100644 > --- a/src/lj_crecord.c > +++ b/src/lj_crecord.c > @@ -78,7 +78,7 @@ static CTypeID argv2ctype(jit_State *J, TRef tr, cTValue *o) > /* Specialize to the string containing the C type declaration. */ > emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, s)); > cp.L = J->L; > - cp.cts = ctype_ctsG(J2G(J)); > + cp.cts = ctype_cts(J->L); > oldtop = cp.cts->top; > cp.srcname = strdata(s); > cp.p = strdata(s); > diff --git a/test/tarantool-tests/fix-argv2ctype-cts-L-init.test.lua b/test/tarantool-tests/fix-argv2ctype-cts-L-init.test.lua > new file mode 100644 > index 00000000..ee45e424 > --- /dev/null > +++ b/test/tarantool-tests/fix-argv2ctype-cts-L-init.test.lua > @@ -0,0 +1,15 @@ > +local tap = require('tap') > +local test = tap.test('fix-argv2ctype-cts-L-init'):skipcond({ > + ['Test requires JIT enabled'] = not jit.status(), > +}) > + > +-- Loading of 'tap' module initialize `cts->L` during parsing. > +-- Run standalone script for testing. > +local script = require('utils').exec.makecmd(arg) > + > +test:plan(1) > + > +local output = script() > +test:is(output, 'OK', 'correct recording with uninitialized cts->L') > + > +test:done(true) > diff --git a/test/tarantool-tests/fix-argv2ctype-cts-L-init/script.lua b/test/tarantool-tests/fix-argv2ctype-cts-L-init/script.lua > new file mode 100644 > index 00000000..2131385a > --- /dev/null > +++ b/test/tarantool-tests/fix-argv2ctype-cts-L-init/script.lua > @@ -0,0 +1,14 @@ > +local ffi = require('ffi') > + > +jit.opt.start('hotloop=1') > + > +local i = 1 > +-- Use `while` to start compilation of the trace at the first > +-- iteration, before `ffi.new()` is called, so `cts->L` is > +-- uninitialized. > +while i < 3 do > + ffi.new('uint64_t', i) > + i = i + 1 > +end > + > +print('OK')