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 C5EB13257D4; Fri, 10 Feb 2023 16:05:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C5EB13257D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1676034321; bh=T3AxapRMagTgehx9xtDa+1ArmTUIltHFPfpczrTs0n4=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=aP1HuF+Bxj8qzXZznJAyn1/HtCr0Kx+GvCS+H93R5qMqhbfqprZaHWvrlT0wGt7P2 H0qrkDu8qdtBOzjgo8J11dg5hpVw0Pl/7HqvFmWoHeD5u4rrYxdN3iKyAfX/YJGRPC BqzQCl7RYndbMng252NFrpFQqG3gVm7e/YAsA7No= 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 54A346ECCD for ; Fri, 10 Feb 2023 16:05:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 54A346ECCD Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1pQT5b-0004ag-8N; Fri, 10 Feb 2023 16:05:19 +0300 To: Sergey Ostanevich , Maxim Kokryashkin Date: Fri, 10 Feb 2023 16:01:46 +0300 Message-Id: <20230210130146.30703-1-skaplun@tarantool.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D919194CF4FC66041196602ED3523C68FCAA1AF2A5B8421A182A05F538085040E525D36FD9FE181D8AD92F97CB96C8B300DD1C4AF6AB1CFE2EA9E02725889D93 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE795530B80AF2ADB7BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F63E14183F8C6AF98638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8230228D291328ED2EAECC08CF93902E3117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520F8AB6B2BE2218126117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637A7EFCB0EB5ACB161EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: BCAA75B3C340DBBEEF3A853C90EA8D50F01536074D6990B7EE9D5CB6078CC77C7978B3EA0AB05FF79016E28473A56E49 X-C1DE0DAB: 0D63561A33F958A5E0FB68FF82F084C1766B88B52DA86C272CD962B457D8CDDD4EAF44D9B582CE87C8A4C02DF684249C2E763F503762DF50F2237FE565727C05 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3455049D7B43D89D646BC58A614E9C02FD23106ACCA9D053AD86320AD555DBAAB7E91F33446B4E94721D7E09C32AA3244C7A1235FBA64A2576E7ABFE343045F92A69B6CAE0477E908D927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXiMEyZTDlISX+dBzNiLiXZe X-DA7885C5: E3EDDE932A1E96387C27B0ADAAC01AA47FC2832FC4FDA850EE734A1FD37D75A1262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73933AF1F914F131DBF5753CFB9DE2F67DD3D4856D6D30260BFF0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit] ARM64: Fix pcall() error case. 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 Reported by Alex Orlenko. (cherry picked from commit b4b2dce9fc3ffaaaede39b36d06415311e2aa516) The `pcall()` assembler preambule modifies `RC` (`x28`) (N args * 8) during the check of the amount of the given arguments. So, this wrong value using in the `fff_fallback` routine leading to a crash on the error throwing, because the Lua stack is filled incorrect and can't be unwound. This patch adds the additional comparison before taking the fallback branch and modifies `RC` only after this branch. Sergey Kaplun: * added the description and the test for the problem Part of tarantool/tarantool#8069 --- PR: https://github.com/tarantool/tarantool/pull/8295 Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-762-arm64-pcall-no-arg Issues: * https://github.com/tarantool/tarantool/issues/8069 * https://github.com/LuaJIT/LuaJIT/issues/762 src/vm_arm64.dasc | 3 ++- test/tarantool-tests/lj-762-pcall-no-arg.test.lua | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/tarantool-tests/lj-762-pcall-no-arg.test.lua diff --git a/src/vm_arm64.dasc b/src/vm_arm64.dasc index f517a808..e8b63d33 100644 --- a/src/vm_arm64.dasc +++ b/src/vm_arm64.dasc @@ -1168,9 +1168,10 @@ static void build_subroutines(BuildCtx *ctx) |//-- Base library: catch errors ---------------------------------------- | |.ffunc pcall + | cmp NARGS8:RC, #8 | ldrb TMP0w, GL->hookmask - | subs NARGS8:RC, NARGS8:RC, #8 | blo ->fff_fallback + | sub NARGS8:RC, NARGS8:RC, #8 | mov RB, BASE | add BASE, BASE, #16 | ubfx TMP0w, TMP0w, #HOOK_ACTIVE_SHIFT, #1 diff --git a/test/tarantool-tests/lj-762-pcall-no-arg.test.lua b/test/tarantool-tests/lj-762-pcall-no-arg.test.lua new file mode 100644 index 00000000..6cbfe707 --- /dev/null +++ b/test/tarantool-tests/lj-762-pcall-no-arg.test.lua @@ -0,0 +1,15 @@ +local tap = require('tap') + +-- Test file to check error raising for `pcall()` without +-- arguments. Regardless that the problem is aarch64-specific, +-- it is good to test it for all arches. +-- See also https://github.com/LuaJIT/LuaJIT/issues/762. +local test = tap.test('lj-762-pcall-no-arg') +test:plan(2) + +local result, err = pcall(pcall) + +test:ok(not result, 'pcall() without args: bad status') +test:like(err, 'value expected', 'pcall() without args: error message') + +os.exit(test:check() and 0 or 1) -- 2.34.1