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 50DA86E210; Wed, 29 Jul 2026 10:39:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 50DA86E210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1785310779; bh=jXrM9EKXtCza4On5UblHYbNVyyYVpdA+Q/y5e2/w4gA=; 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=pt99TrEsqII603A2wuPumLgGgCB9c8XL5HvmNUSNRRu2FlCQ+AOZ/BwXMl0nSM/PG ZWpQrQv2Vau4NPF2+J6KIvrrp71ha9RueuBmPZSF6m2nenTfES2c+LQrR2wCMpIEGX W3Jnb4BQf7Jg6i4u/AOAFQ96d6KvMZnZJYstQTYs= Received: from send60.i.mail.ru (send60.i.mail.ru [89.221.237.155]) (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 2F38C6E210 for ; Wed, 29 Jul 2026 10:39:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2F38C6E210 Received: by exim-smtp-6c76488b9f-xc4vt with esmtpa (envelope-from ) id 1woyt7-000000006sz-0VT4; Wed, 29 Jul 2026 10:39:37 +0300 Date: Wed, 29 Jul 2026 10:39:22 +0300 To: Evgeniy Temirgaleev Message-ID: References: <20260720142430.2571440-1-skaplun@tarantool.org> <1785255790.236205484@f510.i.mail.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1785255790.236205484@f510.i.mail.ru> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD999EC7E29E32078B0E87D26D5D4D3469A37D306C28DB22336182A05F538085040862835B9277B4EB13DE06ABAFEAF6705DD3DDCCC43E531E2A3DD49900C131DE8DE0EE579F5A0FF99 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76D4A2B7BAC4DEDB8EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB553375666E0AFCC7CBCEC7C78CCBBFA03BA0B4429DAB99B0931DBBD3C22BB0348EC2735C389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C04CF195F1528592878941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B601F8F2FECC0250C8CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249F3DD27CEE54E359176E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8BCFA9DE07C563E1613AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E73525A4AB119743A3B3C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A51F6B9B8C97DCACAD5002B1117B3ED696E2A9C5AC056045B9E41E333F9D1358D5823CB91A9FED034534781492E4B8EEAD0AA277257C6A5E3DBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F96AB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659B669D19AEC6B140879425579A372C8835C5C904EB444F2C0166727D3859388D1D7ECE4518FE6AC10B8341EE9D5BE9A0A093D6E6A92ABA34A7A20F769FA29558519D40BABE02533016536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVczkDsfooUjffnYOypFkRZE= X-Mailru-Sender: 520A125C2F17F0B17094CDC02B85F11B83D28DB4CBA2453C3DE06ABAFEAF6705DD3DDCCC43E531E2B7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] FFI: Fix pointer difference operation on 64 bit platforms. 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" Hi, Evgeniy! Thanks for the review! Please consider my answer below. On 28.07.26, Evgeniy Temirgaleev wrote: > Hi, Sergey! Thanks for the patch! > > LGTM with a note on a test, please see. > -- > Best regards, > Evgeniy Temirgaleev > > > > > From: Sergey Kaplun > > To: Sergey Bronnikov , Evgeniy Temirgaleev > > > > Cc: tarantool-patches@dev.tarantool.org, Sergey Kaplun > > > > Date: Monday, July 20, 2026 5:24 PM +03:00 > > From: Mike Pall > > > > Thanks to cuiweixie. > > > > (cherry picked from commit b58b07189521e82c7a8e8bc43fc3c271f89832fd) > > > > The metamethod for FFI pointer subtraction casts the result value to a > > 32-bit value, which leads to invalid results. > > > > This patch removes the excess cast. > > > > Sergey Kaplun: > > * added the description and the test for the problem > > > > Part of tarantool/tarantool#12880 > > --- > > > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1449-fix-ptr-diff-64-bit > > > > Related issues: > > * https://github.com/LuaJIT/LuaJIT/issues/1449 > > * https://github.com/tarantool/tarantool/issues/12880 > > > > src/lj_carith.c | 2 +- > > .../lj-1449-fix-ptr-diff-64-bit.test.lua | 39 +++++++++++++++++++ > > 2 files changed, 40 insertions(+), 1 deletion(-) > > create mode 100644 > > test/tarantool-tests/lj-1449-fix-ptr-diff-64-bit.test.lua > > > > diff --git a/src/lj_carith.c b/src/lj_carith.c > > index eb56d552..3384c2cd 100644 > > --- a/src/lj_carith.c > > +++ b/src/lj_carith.c > > diff --git a/test/tarantool-tests/lj-1449-fix-ptr-diff-64-bit.test.lua > > b/test/tarantool-tests/lj-1449-fix-ptr-diff-64-bit.test.lua > > new file mode 100644 > > index 00000000..032b9b4d > > --- /dev/null > > +++ b/test/tarantool-tests/lj-1449-fix-ptr-diff-64-bit.test.lua > > +jit.opt.start('hotloop=1') > > + > > +for i = 1, 4 do > > + -- Use constants on trace. > > + local delta = 0x80000001ULL > > + local b = 0x700000000000ULL > > + local pt0 = ffi.cast('char *', b) > > + local pt1 = ffi.cast('char *', b + delta) > > + results[i] = pt1 - pt0 > > +end > > + > > > > It seems, we need to add a correct sample to the results, e.g. table.insert(results, diff) It is not necessary. The correctness of the VM is checked in the previous test case. Here we check only consistency between the VM and JIT. So, if JIT behaviour is different the test will fail (also, it means that the JIT result is incorrect, since it doesn't match the correct VM result tested before). Also, if one runs this test without the patch applied, the assertion in `record_check_slots()` is raised, since the resulting value after folding is not the same as given by the VM. > > +test:samevalues(results, 'consistent JIT and VM behaviour for ptr > > subtraction') > > + > > +test:done(true) > > -- > > 2.55.0 > > -- Best regards, Sergey Kaplun