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 E15C26EC40; Fri, 4 Jun 2021 16:57:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E15C26EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622815039; bh=s81WbuMAx8f1KaOSQYbCS2WLt3Sckc7FTmFUd3/yMAA=; 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=HturK2X6JGwHsaKu1f7S9izoPD88us2ZbEalBsiH11pB454yTCCM+RkdxBwzalrIl GZRUkuPidKZRPhXp7Z6loFl1bihxrENwea1G8AjZG9QsaBkKFUoMJ/7M1Gx1Q7+Da6 MXTu1fbmhm+NOzQ1i88HUp2Dpw4EoNNvs0Tctwh4= Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 B33EC6EC40 for ; Fri, 4 Jun 2021 16:57:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B33EC6EC40 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lpAK4-0008CS-Sa; Fri, 04 Jun 2021 16:57:17 +0300 Date: Fri, 4 Jun 2021 16:56:06 +0300 To: Sergey Ostanevich Message-ID: References: <9F30A4EA-54A0-4D2A-A018-20CAB72A4E3B@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9F30A4EA-54A0-4D2A-A018-20CAB72A4E3B@tarantool.org> X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C540E30C2BDD69416C6E46C178CD572CB10182A05F538085040045AAD88C8D2B5B71967D53F49B237798BB11A93C34E10836B892E499FF812FB X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F6EE1C40B2E8BE15EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372BE3E2E75E3847F48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CF14E542F45E2A2C6CF14FC055DCEBED117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD186FD1C55BDD38FC3FD2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6D0C9BB9AE6BD5D69089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A56F1BF8F57E45858D16FEA8221F8C75A87A1BF784B0C8D2B9D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75FBC5FED0552DA851410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346BEB6F73FB9D1E4AF491930EF2E3FFC30DBED7887C4607210C486D80F4008A7B5744BA440E9E94541D7E09C32AA3244C8F07917831E1F30B22E800F1F5EEDFE7E3D93501275E802FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojz99asgmzejqWFo59SYHV/Q== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822928F7FDD5931770885DAD484EB86DEED0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED567EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 4/4] ARM64: Fix xpcall() error case (really). 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! Thanks for the review! On 02.06.21, Sergey Ostanevich wrote: > Hi! > > Thanks for the patch! > > Just some updates to the message, LGTM. > > Sergos > > > On 24 May 2021, at 16:27, Sergey Kaplun wrote: > > > > From: Mike Pall > > > > Thanks to François Perrad and Stefan Pejic. > > > > (cherry picked from commit d417ded17945b4211608d497d50b509e0274f5e0) > > > > Premature decrementing VM's RC register before switch to fff_fallback > decrement of > > > handler during processing `xpcall()` fast function leads to incorrect > > stack layout (not enough arguments on stack), when `xpcall()` calls > > without a second argument or if it is not a function (see <301-basic.t> > > test in lua-Harness test suite). While further error processing it leads > > to incorrect error message, due to stack inconsistency. > > Mention this test verifies the patch behavior. > > > > > This patch stores intermediate result into TMP1 register (it does not > > determine fallback's behaviour and there is no way to return from > > fallback back to xpcall processing with spoiled TMP1) and moves RC > > setting after possible switching to fallback handler. > the switch the > > > > > Sergey Kaplun: > > * added the description for the problem > > > > Resolves tarantool/tarantool#6093 > > Part of tarantool/tarantool#5629 > > --- The new commit message is: Branch is force-pushed. =================================================================== ARM64: Fix xpcall() error case (really). Thanks to François Perrad and Stefan Pejic. (cherry picked from commit d417ded17945b4211608d497d50b509e0274f5e0) Premature decrement of VM's RC register before switch to fff_fallback handler during processing `xpcall()` fast function leads to incorrect stack layout (not enough arguments on stack), when `xpcall()` calls without a second argument or if it is not a function (see test in lua-Harness test suite). While further error processing it leads to incorrect error message, due to stack inconsistency. This patch stores intermediate result into TMP1 register (it does not determine fallback's behaviour and there is no way to return from fallback back to xpcall processing with spoiled TMP1) and moves RC setting after the switch to the fallback handler. Sergey Kaplun: * added the description for the problem Resolves tarantool/tarantool#6093 Part of tarantool/tarantool#5629 =================================================================== > > src/vm_arm64.dasc | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/src/vm_arm64.dasc b/src/vm_arm64.dasc > > index e16a77ab..6e298255 100644 > > --- a/src/vm_arm64.dasc > > +++ b/src/vm_arm64.dasc > > @@ -1183,7 +1183,7 @@ static void build_subroutines(BuildCtx *ctx) > > |.ffunc xpcall > > | ldp CARG1, CARG2, [BASE] > > | ldrb TMP0w, GL->hookmask > > - | subs NARGS8:RC, NARGS8:RC, #16 > > + | subs NARGS8:TMP1, NARGS8:RC, #16 > > | blo ->fff_fallback > > | mov RB, BASE > > | asr ITYPE, CARG2, #47 > > @@ -1191,6 +1191,7 @@ static void build_subroutines(BuildCtx *ctx) > > | cmn ITYPE, #-LJ_TFUNC > > | add PC, TMP0, #24+FRAME_PCALL > > | bne ->fff_fallback // Traceback must be a function. > > + | mov NARGS8:RC, NARGS8:TMP1 > > | add BASE, BASE, #24 > > | stp CARG2, CARG1, [RB] // Swap function and traceback. > > | cbz NARGS8:RC, ->vm_call_dispatch > > -- > > 2.31.0 > > > -- Best regards, Sergey Kaplun