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 4BDAF9A6E9F; Tue, 12 Mar 2024 14:58:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4BDAF9A6E9F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1710244732; bh=irynhjLplyLRmy5Daz/j1RY2RIMmuzwJCsRPwHYtGrM=; 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=Oq0qORoIj5+wHZkYCq5HRnvX2RmPqKW9mUc9eXS7yXxFuWsvbEnLT+k0qlYVP8Bhl /Zm5k8pwDx2plsog2o6KlC6ovYzNNFbuIGDAStUljeMesgdeiO9iiFhwgFOkKD1iKT VmJRGvQK0ER2iMkyx0AMDDi+h9TQyA/j5dsf6+/E= Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [95.163.41.99]) (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 8E4C39A6E9F for ; Tue, 12 Mar 2024 14:58:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8E4C39A6E9F Received: by smtp61.i.mail.ru with esmtpa (envelope-from ) id 1rk0mP-0000000551E-06aR; Tue, 12 Mar 2024 14:58:49 +0300 Date: Tue, 12 Mar 2024 14:58:47 +0300 To: Sergey Kaplun Message-ID: <3fdmcpw5ar4shu4om6ue2xdk7b2jjopuwf2sltf635ewgywbyz@ehjelhcmcwjn> 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: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD987C0EE6E7F0A597D77DAD88DB19A0E871D0E83388B9166C4182A05F538085040AAB6FDCB523AACDCD27678DDAA8063141406A29A70A146E711505B6E25844D98B7E140D37D564E50 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72424932217190DC2EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063798FF8892961A0B3C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8C06CA75F942DE39277E4B05516E56397A45F3E3C26B279ACCC7F00164DA146DAFE8445B8C89999728AA50765F7900637CAEE156C82D3D7D9389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC81D471462564A2E19F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE33AC447995A7AD182BEBFE083D3B9BA73A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735BA6625F88748EAEFC4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A52019EA0D439AB08A5002B1117B3ED69637CA7F8FFBA35E73BFF4097FFC9E796F823CB91A9FED034534781492E4B8EEAD5E90D3DD2A5B7EAFBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFF87354B209E7DF98DAE01E1C55BA911DC2F8B45BF77EBF79849433ED87F32985192AF36DABE858457C77D8D956826D3352275953DC9850CE4B2BE399E83713DAE41133A0602487DC5F4332CA8FE04980913E6812662D5F2A54F6898A6FDCBDC72A617DFBE5FEC2C6383653B6C8D9AE0FD16FCAA6493B703A X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojWDseZ7hBpni5L5LAWuEwNw== X-DA7885C5: 6A122AA0F36600BDF255D290C0D534F9F2362D3B20AD2C9A94CFD8E0420BA1927EAAA6D68A5F38225B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393590D8C940224AE33752CE23EB7272ECEBAB603027443F7304078777B427D8881563E610FBBDBB4C842051EA7CBBFB5097AB92FA4D94F20E3E33C1B503AADE26945BD1C3CC395C826B4A721A3011E896F 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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the clarifications! See my answers below. On Tue, Mar 12, 2024 at 08:43:44AM +0300, Sergey Kaplun wrote: > 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]. Then add a comment mentioning that test fails only for the ASAN build. It is quite easy to miss. > > > > > 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. Please drop a comment mentioning that. > > > > + > > > +-- 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