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 0EC2B6EC59; Wed, 10 Mar 2021 17:59:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0EC2B6EC59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1615388350; bh=41XSG1XtP44N/Z6EV7v7veC1w0uvyQEBgNGuzaoo4og=; h=In-Reply-To:Date:References:To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=c+633EzngKXrONHoM3AulCaKYlehMcWua2c7QV6Zn3felFxClpzsd9CujAa2miyNG lii6B+xnxdkAc50SqcWCeqQDcUw+6gIiRT2d9vLt3G/iRK0m3u9RfjmjnnyMCnOo6A PeLF2nuym6kCzRC1SuN+ps9cd3ZhbcAMRnZpMA0E= Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (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 50D276EC59 for ; Wed, 10 Mar 2021 17:59:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 50D276EC59 Received: by smtp36.i.mail.ru with esmtpa (envelope-from ) id 1lK0Il-00043P-6Q; Wed, 10 Mar 2021 17:59:07 +0300 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) In-Reply-To: <20210309175422.25432-1-skaplun@tarantool.org> Date: Wed, 10 Mar 2021 17:59:06 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <51AE3320-136E-422E-9BCC-AFA4A338B77A@tarantool.org> References: <20210309175422.25432-1-skaplun@tarantool.org> To: Sergey Kaplun X-Mailer: Apple Mail (2.3654.60.0.2.21) X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D3134714A9BDB69B4FDE681076A75050A04AB89703C50EB600894C459B0CD1B988C4BAED15D7A766A4BAF657BEE4C67F99EB0E79AEE2901716B5ACA2CA2E2F10 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7922FDBD9EBA3C5B4B287FD4696A6DC2FA8DF7F3B2552694A4E2F5AFA99E116B42401471946AA11AF0E30A4C9C8E338DA62F001A90027CA0C8F08D7030A58E5ADC58D69EE07B14084C6CDE5D1141D2B1C5FC9870AFB3D45C89C40E6D79F5E49D1D981A5FE40BECBAB9FA2833FD35BB23D9E625A9149C048EE33AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B2EE5AD8F952D28FBA471835C12D1D977C4224003CC836476EB9C4185024447017B076A6E789B0E975F5C1EE8F4F765FCE3F710C1C8B542CF3AA81AA40904B5D9CF19DD082D7633A078D18283394535A93AA81AA40904B5D98AA50765F790063784B29C251326BA11D81D268191BDAD3D698AB9A7B718F8C442539A7722CA490C13377AFFFEAFD26923F8577A6DFFEA7C2C2559B29ED8195093EC92FD9297F6715571747095F342E857739F23D657EF2BD5E8D9A59859A8B6045A9A90E9EED90B089D37D7C0E48F6C5571747095F342E857739F23D657EF2B6825BDBE14D8E702E4EE3A04994FF497E5BFE6E7EFDEDCD789D4C264860C145E X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24A6D60772A99906F8E1CD14B953EB46D314CC0D20A7E2C11355D89D7DBCDD132 X-C1DE0DAB: 0D63561A33F958A5022CF577FFF73D09FB1765FBAAE94AE85C6D6904EA402F24D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75F04B387B5D7535DE410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D347D10A9FCB2A62DFE0ED25CC41899FFF93FCDCBCBD3BC6896BB5E2391524049D85E8EA250AF83F36F1D7E09C32AA3244CE01652881A24EFF01636A8A331E4CBAC3FD9C8CA1B0515E0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojsR8tyFmO15NQ7qjUTwDkrg== X-Mailru-Sender: 455D65AE3A139168626D8C76E86D3AC088C4BAED15D7A766A4BAF657BEE4C67FDDAC019A3742A8B676D79013C85012CDC77752E0C033A69E4BBE7EBD99111A499D0AB74157175C036C18EFA0BB12DBB0 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] memprof: report stack resizing as internal event 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 Ostanevich via Tarantool-patches Reply-To: Sergey Ostanevich Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the patch! > On 9 Mar 2021, at 20:54, Sergey Kaplun wrote: >=20 > Resizing of the Lua stack is not reported as internal allocation. > Moreover, it may lead to crash inside Lua or FF frames. >=20 > Profiler performs reallocation first and after reports corresponding > event. When the stack is resized for local function arguments, the = link > to previous frame is invalid in the cause of reallocation. Therefore, ^^^^^^^^ case > assertion in `debug_framepc()` failes, because of invalid function fails. ^^^ is it just dubbing the link=20= is invalid? Then just = remove. > reference at previous frame. >=20 > Resolves tarantool/tarantool#5842 > Follows up tarantool/tarantool#5442 > --- > Branch: = https://github.com/tarantool/luajit/tree/skaplun/gh-5842-memprof-core-on-r= esizestack > Tarantool branch: = https://github.com/tarantool/tarantool/tree/skaplun/gh-5842-memprof-core-o= n-resizestack > Issue: https://github.com/tarantool/tarantool/issues/5842 >=20 >=20 > src/lj_state.c | 6 ++++++ > .../misclib-memprof-lapi.test.lua | 18 ++++++++++++++++++ > 2 files changed, 24 insertions(+) >=20 > diff --git a/src/lj_state.c b/src/lj_state.c > index 1ed79a5..ea9abd4 100644 > --- a/src/lj_state.c > +++ b/src/lj_state.c > @@ -64,7 +64,11 @@ static void resizestack(lua_State *L, MSize n) > MSize oldsize =3D L->stacksize; > MSize realsize =3D n + 1 + LJ_STACK_EXTRA; > GCobj *up; > + int32_t old_vmstate =3D G(L)->vmstate; > + > = lua_assert((MSize)(tvref(L->maxstack)-oldst)=3D=3DL->stacksize-LJ_STACK_EX= TRA-1); > + > + setvmstate(G(L), INTERP); This looks like a hack. But even so - why not to return it back right = after the realloc, where you supposedly use lua_getinfo?=20 The righteous way would be to fix the debug machinery anyhow. > st =3D (TValue *)lj_mem_realloc(L, tvref(L->stack), > (MSize)(oldsize*sizeof(TValue)), > (MSize)(realsize*sizeof(TValue))); > @@ -80,6 +84,8 @@ static void resizestack(lua_State *L, MSize n) > L->top =3D (TValue *)((char *)L->top + delta); > for (up =3D gcref(L->openupval); up !=3D NULL; up =3D gcnext(up)) > setmref(gco2uv(up)->v, (TValue *)((char *)uvval(gco2uv(up)) + = delta)); > + > + G(L)->vmstate =3D old_vmstate; > } >=20 > /* Relimit stack after error, in case the limit was overdrawn. */ > diff --git a/test/tarantool-tests/misclib-memprof-lapi.test.lua = b/test/tarantool-tests/misclib-memprof-lapi.test.lua > index 1c36c8a..93cc348 100644 > --- a/test/tarantool-tests/misclib-memprof-lapi.test.lua > +++ b/test/tarantool-tests/misclib-memprof-lapi.test.lua > @@ -125,5 +125,23 @@ test:ok(check_alloc_report(alloc, 25, 18, 100)) > -- Collect all previous allocated objects. > test:ok(free.INTERNAL.num =3D=3D 102) >=20 > +-- Test for https://github.com/tarantool/tarantool/issues/5842. > +-- We do not interested in report itself. We -> ourselves? > +misc.memprof.start("/dev/null") > +-- We need to cause stack resize for local variables at function > +-- call. Let's create a new coroutine (all slots are free). > +-- It has 1 slot for dummy frame + 39 free slots + 5 extra slots > +-- (so-called red zone) + 2 * LJ_FR2 slots. So 50 local variables > +-- is enough. > +local payload_str =3D "" > +for i =3D 1, 50 do > + payload_str =3D payload_str..("local v%d =3D %d\n"):format(i, i) > +end > +local f, errmsg =3D loadstring(payload_str) > +assert(f, errmsg) > +local co =3D coroutine.create(f) > +coroutine.resume(co) > +misc.memprof.stop() > + > jit.on() > os.exit(test:check() and 0 or 1) > =E2=80=94=20 > 2.28.0 >=20 Regards, Sergos