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 CDF97C05860; Wed, 10 Jul 2024 17:08:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CDF97C05860 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1720620500; bh=5Ul85ue/8zRtgrXE9pb4cKL/CFQUeyt+wSu1Dl0Lm80=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ewEwS7SDxvf6VgYJ5/yyIgeUtX4fpwGtjAviCil7hDVtkAqdPowa8NLV/oXD2gpfF wWa0KpKYiIg0fepZdmjaw5WgelPxkzJ4jNa6YYjMK0oCML3OJG5PE1GtxvNiCVIFNB wKI+cAn6Qevbj5JaZ8K4LWIq7K8mEFRijRO6b0i8= Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [95.163.41.73]) (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 EB546C0585E for ; Wed, 10 Jul 2024 17:08:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EB546C0585E Received: by exim-smtp-687d8cf49b-mw8vp with esmtpa (envelope-from ) id 1sRXzW-00000000EId-0Tp5; Wed, 10 Jul 2024 17:08:18 +0300 Date: Wed, 10 Jul 2024 17:08:09 +0300 To: Sergey Bronnikov Cc: Sergey Bronnikov , tarantool-patches@dev.tarantool.org Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9985AA43F8E1EDB6EC826BC3B15056091F13DE470E0F4F10D00894C459B0CD1B9D2FBE0F8E434800103ED270C30F246C58196477BD0EF9960B08AE8E34251B4B11BB59B39F4C00062 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77603ADE015AF816DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374D4854EC7C9372F88638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8E31DB23E08C68ACA5313273E60168994FB562E25D4FC9AECCC7F00164DA146DAFE8445B8C89999728AA50765F790063783E00425F71A4181389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC81D471462564A2E19F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BB9CEE4F2B4A90F8475ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A5FCB6CCB89DF94E615002B1117B3ED696F79892AC703EBC07FB820E9FE7BD014C823CB91A9FED034534781492E4B8EEAD9DB614F8F96CFA30BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D34023CA4E4726A7D6C7D13A21B8302B29909BF3AA6C8A3D28D0C0EB4FD092FD4C5B6293470FDC49FA21D7E09C32AA3244C96F9BC1A533DB7A177DD89D51EBB7742DC765D3807F73262EA455F16B58544A2557BDE0DD54B3590A5AE236DF995FB59829709634694AABAED6A17656DB59BCAD427812AF56FC65B X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojYxP1dNBoSZnczGw5zxkwSA== X-DA7885C5: C87667FDEC508F08F255D290C0D534F997AD90B8176C7C1307F65A3955CD53790D7A0882121523C95B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393C6D0B12EA33CAA9BEAD6E08FCC77803582A5989E09CC892C5FAB40CAE4D3EF01E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/2][v2] FFI: Turn FFI finalizer table into a proper GC root. 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the fixes! LGTM, after fixing minor comments below. On 10.07.24, Sergey Bronnikov wrote: > Hi, Sergey > > thanks for review. Fixes applied and force-pushed. > > Sergey > > > On 09.07.2024 15:14, Sergey Kaplun via Tarantool-patches wrote: > > Hi, Sergey! > > Thanks for the patch! > > Please consider my comments below. > > > > On 09.07.24, Sergey Bronnikov wrote: > >> From: Mike Pall > >> > > Minor: "will be collected at the end of the cycle if it is created after > > the start phase." > > Updated. | Previous patch fixes the problem partially because the introduced | GC root may not exist at the start phase of the GC cycle. In that | case, the cdata finalizer table will be collected at the end of | the cycle. Minor: "cycle (since it isn't marked because it is not accessible from any GC root)." | Access to the cdata finalizer table exhibits heap use | after free. The patch turns the finalizer table into a proper > > >> diff --git a/test/tarantool-c-tests/lj-1168-heap-use-after-free-on-access-to-CTState-finalizer.test.c b/test/tarantool-c-tests/lj-1168-heap-use-after-free-on-access-to-CTState-finalizer.test.c > >> index c388c6a7..259528cb 100644 > >> --- a/test/tarantool-c-tests/lj-1168-heap-use-after-free-on-access-to-CTState-finalizer.test.c > >> +++ b/test/tarantool-c-tests/lj-1168-heap-use-after-free-on-access-to-CTState-finalizer.test.c > >> + > >> + /* Not trigger GC during `lua_openffi()`. */ > >> + lua_gc(L, LUA_GCSTOP, 0); > > Maybe it is worth adding this GC stop for the first test case too to > > make it more robust. > Ok, I'll add. Thanks! > > > >> + > >> + int res = luaL_loadbufferx(L, buff, sizeof(buff) - 1, "chunk", "t"); I suggest renaming "chunk" to the "test_chunk" here too. Also, please add here comment about `sizeof(buff) - 1` too. > >> + assert_true(res == LUA_OK); > --- a/test/tarantool-c-tests/lj-1168-unmarked-finalizer-tab.test.c > +++ b/test/tarantool-c-tests/lj-1168-unmarked-finalizer-tab.test.c > @@ -78,7 +78,10 @@ unmarked_finalizer_tab_gcsweep(void *test_state) >         lua_gc(L, LUA_GCSTOP, 0); > >         int res = luaL_loadbufferx(L, buff, sizeof(buff) - 1, "chunk", > "t"); > -       assert_true(res == LUA_OK); > +       if (res != LUA_OK) { > +               test_comment("error loading Lua chunk: %s", > lua_tostring(L, -1)); Code line length is more than 80 symbols. (Same for the previous commit.) > +               bail_out("error loading Lua chunk"); > +       } > >         /* Finish GC cycle. */ >         while (!lua_gc(L, LUA_GCSTEP, -1)); > > > > >> + > >> + /* Finish GC cycle. */ Let's add "to collect the finalizer table." to be consistent with another test. > >> + while (!lua_gc(L, LUA_GCSTEP, -1)); > >> + -- Best regards, Sergey Kaplun