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 7EF1C9A2C57; Tue, 12 Mar 2024 08:47:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7EF1C9A2C57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1710222467; bh=dSng8qbANxRGcbFMBcQ6MUBUod3wovl2ab+x3hqRxW0=; 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=ywquFUY+YhIRTPG+JCL5X8K501eLPr/uHgZamV/dbBcjO66fd0nhW1/TH/nlk8Vtx Ei8qqHkxKZ4hozEKIizgaf59cMHKVu7/mCUH3NAvr8YU1IhN9Mhc8Ko4gyIVfkD39K +ovmHqFw1xM19Hd28chchMS7PQe/HumoHwCIixw8= Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [95.163.41.86]) (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 3E9609A2C57 for ; Tue, 12 Mar 2024 08:47:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3E9609A2C57 Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1rjuzI-00000002bIK-2RK7; Tue, 12 Mar 2024 08:47:45 +0300 Date: Tue, 12 Mar 2024 08:43:44 +0300 To: Maxim Kokryashkin Message-ID: References: <20240311103701.24502-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD93B4404EFBC5FECACA9EC236B2026148BC832E235743ACE29182A05F5380850404C228DA9ACA6FE27D409E7E00A42E3C6F378A8CA21F699D60C9A49563216D1DB3CF4232FB82802E10650F91B75C56BA3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE74B51810D54EC17F0C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE78C6616F30072131EEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B73AB1701401CD871C02F1BDFB2C2CB0544D40826E730C8E797DF68D89A191A50A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE767883B903EA3BAEA9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3E478A468B35FE767117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947C2FFDA4F57982C5F42E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F616AD31D0D18CD5C262FEC7FBD7D1F5BB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A586F71A0FA9F47FD35002B1117B3ED6965CD0FC72A0810F62C66B2B37046EC955823CB91A9FED034534781492E4B8EEADF5E532225D4D775BBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF7F47F6748AC2016027B7CD93E87F33DC818ADC57C73937908CD1877DAD5A7B303D7E4ABC8EFFEBBE748ED927723DE83F9538A30EF2F67971023FE9BE3D0E6FA79B56A346EDF958835F4332CA8FE04980913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojWDseZ7hBpnhNQiA+evyzBg== X-DA7885C5: 92D06390FB86091EF255D290C0D534F978EE0F920B55F313A2E083DD0951580271E83198A5936F555B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393590D8C940224AE3355F011167F2EFA850C250AD38D4C771DBA161D859E079E72E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Handle stack reallocation in debug.setmetatable() and lua_setmetatable(). 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, Maxim! Thanks for the review! Please consider my answers below. On 11.03.24, Maxim Kokryashkin wrote: > Hi, Sergey! > Thanks for the patch! > Please consider my comments below. > > The test passes before the patch, as can be seen in CI for this branch: > https://github.com/tarantool/luajit/tree/mkokryashkin/test I see quite the opposite [1][2]. > > On Mon, Mar 11, 2024 at 01:37:01PM +0300, Sergey Kaplun wrote: > > --- > > > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1172-debug-handling-ref > > Tarantool PR: https://github.com/tarantool/tarantool/pull/9786 > > Related issues: > > * https://github.com/tarantool/tarantool/issues/9595 > > * https://github.com/LuaJIT/LuaJIT/issues/1172 > > > > > > src/lj_api.c | 1 + > > .../lj-1172-debug-handling-ref.test.lua | 30 +++++++++++++++++++ > > 2 files changed, 31 insertions(+) > > create mode 100644 test/tarantool-tests/lj-1172-debug-handling-ref.test.lua > > > > diff --git a/src/lj_api.c b/src/lj_api.c > > index 3bacad33..2e915306 100644 > > --- a/src/lj_api.c > > +++ b/src/lj_api.c > > diff --git a/test/tarantool-tests/lj-1172-debug-handling-ref.test.lua b/test/tarantool-tests/lj-1172-debug-handling-ref.test.lua > > new file mode 100644 > > index 00000000..cac1c223 > > +local jdump = require('jit.dump') > > + > > +test:plan(1) > > + > > +jdump.start('t', '/dev/null') > Why do we need that call here? Because we need to trigger the VM event, see the comment below. > > + > > +-- Use `coroutine.wrap()` to create a new Lua stack with a minimum > > +-- number of stack slots. > > +coroutine.wrap(function() > > + -- "TRACE flush" event handler causes stack reallocation and > How is flush event caused? By the `jit.dump()` as most VM events. > > + -- leads to heap-use-after-free. This event handler is called > > + -- because all traces are specialized to base metatables, so > > + -- if we update any base metatable, we must flush all traces. > > + debug.setmetatable(1, {}) > > +end)() > > + > > +test:ok(true, 'no heap-use-after-free error') > > + > > +test:done(true) > > -- > > 2.44.0 > > [1]: https://github.com/tarantool/luajit/actions/runs/8239484621/job/22532793546#step:6:1344 [2]: https://github.com/tarantool/luajit/actions/runs/8239484621/job/22532793913#step:6:1363 -- Best regards, Sergey Kaplun