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 04D4F6BD18; Mon, 12 Apr 2021 12:36:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 04D4F6BD18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618220216; bh=+ihNV0YHecRF1kxUpiDBvixL4Qp3iOAVa0YDWZtYAFQ=; 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=tt1QvhquEj0b6FRdwafNjNxli/yBK9fpSWh91VBpaGpaZDRO5uDeWdNC1sd3gMerB +NxmG2hjerGPv9xtAsjQztlB25Top7YU8fIhh6WNfjEAk2AajDiUX4W+AvnmZHhz6Z ayi5bWtF7smw9tDznBSaw6sBGLK3MxFD7wfl56d8= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [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 755876EC5B for ; Mon, 12 Apr 2021 12:36:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 755876EC5B Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lVt01-0004Oy-CM; Mon, 12 Apr 2021 12:36:53 +0300 Date: Mon, 12 Apr 2021 12:36:41 +0300 To: Sergey Kaplun Message-ID: <20210412093641.GU29703@tarantool.org> References: <20210331192350.GK29703@tarantool.org> <20210406213716.GM29703@tarantool.org> <20210407161131.GN29703@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480257C85EA0BB7A95D5E28B957962BB550182A05F538085040FE81BDA836E457E99F65AFC3387FF36BADC978BE4AA263ECFED4220AE9C8E377 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A3295C83650092F9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006376B6794A086D6ADA58638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2EA1437B16062702EFB508E76BAB6604C06708AB62ED68B8ED2E47CDBA5A96583C09775C1D3CA48CFCA5A41EBD8A3A0199FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C317B107DEF921CE79117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B53A69B3AC30C7B9475ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A5279914722A02467D5DCE554F0938CEBED5F6075F7B4DF49AD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3429499E429979B7C77C481B02012841BED73852E65A0AC670D27DA4580405B933A4DABF4EE59F52671D7E09C32AA3244C17B4787B9D0082F059440B68BAEB866E853296C06374E602927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojq8JA+pXcDunwtw8v2kG4ow== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382254258BB8D21383B436A5734805C93036A7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 luajit 23/30] test: disable PUC Lua test for fast function name 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, On 07.04.21, Sergey Kaplun wrote: > Igor, > > On 07.04.21, Igor Munkin wrote: > > Sergey, > > > > On 07.04.21, Sergey Kaplun wrote: > > > Igor, > > > > > > > > > > > > > > > > diff --git a/test/PUC-Lua-5.1-tests/errors.lua b/test/PUC-Lua-5.1-tests/errors.lua > > > > > > > index cf24e40..af776a7 100644 > > > > > > > --- a/test/PUC-Lua-5.1-tests/errors.lua > > > > > > > +++ b/test/PUC-Lua-5.1-tests/errors.lua > > > > > > > @@ -105,9 +105,13 @@ while 1 do > > > > > > > insert(prefix, a) > > > > > > > end]], "global 'insert'") > > > > > > > > > > > > > > -checkmessage([[ -- tail call > > > > > > > - return math.sin("a") > > > > > > > -]], "'sin'") > > > > > > > +-- LuaJIT: Can't determine bytecode position for non Lua functions > > > > > > > +-- (in particular for fast functions) and, therefore, detect fast > > > > > > > +-- function names for errors in tail calls. > > > > > > > > > > > > This is kinda gibberish. I've tried the following snippets and can't > > > > > > understand what do you mean by this comment. > > > > > > > > > > > > | $ luajit -e 'function q(a) return math.sin(a) end q("a")' > > > > > > | luajit: (command line):1: bad argument #1 to 'q' (number expected, got string) > > > > > > | stack traceback: > > > > > > | [C]: in function 'q' > > > > > > | (command line):1: in main chunk > > > > > > | [C]: at 0x5610e8497eb0 > > > > > > | $ luajit -e 'loadstring("return math.sin([[a]])")()' > > > > > > | luajit: (command line):1: bad argument #1 to '?' (number expected, got string) > > > > > > | stack traceback: > > > > > > | [builtin#43]: at 0x7fc0f807ad10 > > > > > > | (command line):1: in main chunk > > > > > > | [C]: at 0x55c1e85c7eb0 > > > > > > > > > > > > I understand the first result. The second result surprised me, but I've > > > > > > never investigated how loadstring call works (it looks like specifics of > > > > > > VARG frame, but this is a wild guess). But neither of them fits your > > > > > > explanation. The root cause is the same: callee uses caller frame, since > > > > > > caller doesn't need it anymore. Could you please clarify yours? > > > > > > > > > > This is not about `loadstring()` at all: > > > > > > > > > > | luajit -e 'return math.sin"a"' > > > > > | luajit: bad argument #1 to '?' (number expected, got string) > > > > > | stack traceback: > > > > > | [builtin#43]: at 0x7f7c2ca6dbe0 > > > > > | [C]: at 0x558b0cd4cec0 > > > > > > > > > > The guest frame is looked like the following (when the error thrown): > > > > > | 0x40001938 [ ] VALUE: string "number expected, got string" @ 0x40008380 > > > > > | 0x40001930 [ B ] VALUE: string "a" @ 0x40008250 > > > > > | 0x40001928 [ ] FRAME: [CP] delta=3, fast function #44 > > > > > > > > > > When LuaJIT tries to detect function's name it determines bytecode > > > > > position first, via `debug_framepc()`. But it can't determine bytecode > > > > > position for non-Lua functions: > > > > > > > > What? Both luajit-gdb.py and LuaJIT itself reports the fast function ID > > > > and this is its name. > > > > > > Yes, what is your question about? > > > > Then what's the problem with name resolving? > > As I said before for tailcall there is no creation of additional Lua > frame. Without it guest frame is looks like the following: > > | 0x40001950 [ T ] > | 0x40001948 [ ] VALUE: string "number expected, got string" @ 0x40008380 > | 0x40001940 [ B ] VALUE: string "a" @ 0x40008280 > | 0x40001938 [ ] FRAME: [LP] delta=1, fast function #44 > | 0x40001930 [ ] FRAME: [V] delta=1, Lua function @ 0x40008248, 0 upvalues, "=(command line)":0 > | 0x40001928 [ ] FRAME: [CP] delta=3, Lua function @ 0x40008248, 0 upvalues, "=(command line)":0 > > `err_argmsg()` function uses `lj_debug_funcname()`, which uses > `debug_framepc()`, which can't get bcpos required for function prototype > detection (see explanation with code sources above). So, LuaJIT can't > detect fast function names for tailcalls on C frame. And *this* is finally a good explanation of the issue you resolved here. Please adjust the original comment considering the wording above. After this change made, the patch LGTM, thanks! > > > > > > > > > > > > > > > > > > > > | if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */ > > > > > | return NO_BCPOS; > > > > > > > > > > > > > > > > > > +-- The test is disabled for LuaJIT. > > > > > > > +-- checkmessage([[ -- tail call > > > > > > > +-- return math.sin("a") > > > > > > > +-- ]], "'sin'") > > > > > > > > > > > > > > checkmessage([[collectgarbage("nooption")]], "invalid option") > > > > > > > > > > > > > > > > > > > -- > > > Best regards, > > > Sergey Kaplun > > > > -- > > Best regards, > > IM > > -- > Best regards, > Sergey Kaplun -- Best regards, IM