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 6BE12673962; Mon, 23 Oct 2023 12:27:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6BE12673962 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1698053258; bh=5s0LXVrNA04/eqz1fS1UYNX557VPbsX4YncTOnkKMqA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gPPsSSQmFa5vGCi496RQ91aQTim29Uxt9mumQgLkiSHAC0ew6o82+AIjT4PAjLH4C N3/91+33v0AIS+S2PxDDssJ5I4Bwao5gjLOM5Rp5WcK/B9cOUa2Lq1jgX5cehJQPyE HRTnoN2bD+3XjEYWorfPPPaQEIwIN32a3kMyGzB4= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 6184F673962 for ; Mon, 23 Oct 2023 12:26:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6184F673962 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1qurCn-0007cl-DD; Mon, 23 Oct 2023 12:26:37 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Mon, 23 Oct 2023 12:22:02 +0300 Message-ID: <30f685beb2bf4ce39dd82ede7b10c821af5c6f0d.1698049570.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9C197A170B57C5E433214076C7295A72B7A923EBE5E68280500894C459B0CD1B971F349B55288C1961EBB16FF76E8BDEB08F89D8EC0FEE90F54C85456B1E49444 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE75644E22E05AA81AEB287FD4696A6DC2FA8DF7F3B2552694A4E2F5AFA99E116B42401471946AA11AF0E30A4C9C8E338DA86614E11AFA257BF8F08D7030A58E5AD1A62830130A00468AEEEE3FBA3A834EE7353EFBB55337566F4AE8016BBA3C0E901B082DB403C90A6C9A7E1F664F4DFEAA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE7A6779F98BF527B7A9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3E3800B164E348C91117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947C989FD0BDF65E50FB2E808ACE2090B5E1725E5C173C3A84C317B107DEF921CE79089D37D7C0E48F6C8AA50765F7900637089291438AC96012731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A513BA0DA46714B809F5A1C08BD931AD5FA4D47B75A74DC205F87CCE6106E1FC07E67D4AC08A07B9B04CB6874B0BCFF0B89C5DF10A05D560A950611B66E3DA6D700B0A020F03D25A092FFDA4F57982C5F4CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF3C4F19A825BA2F280D6C008FA5B8D5A6AD8E9A63C3960307DE107A0571ADE94025059624982F7461A8B50B9382ADB12A29AB139BE8C7B204FDB7549818360464A74DFFEFA5DC0E7F02C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojqlVu258LHAGBtGS49m/iUQ== X-DA7885C5: FDEEC343C29BAD3A7C62A0077695275C2A4E1BCBF9EEC4D1D93D5E141D72919D262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73930F533AC2B33E986BA5257E5938F7A8121EE39DF505FA487A0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [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 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" 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') -- 2.42.0