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 5A61E404481; Thu, 9 Nov 2023 15:08:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5A61E404481 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1699531731; bh=4/BQL3MWrZX8dd7XN5xFTZPR5PISsIaa9y59LVb5O7E=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=BlIx7VHl5tC55MCbEMpOOkGgqi3AxLVLVSnPFcOZjSV4ValFqqhwd/GITqjQxOVAF pEbe3wSaJes9lFJlvSC9/oSEC/0Il6L9D9KueXG1cXOQtiMnzUnoa97rmqB0A4wlFG MYauxk8tIDJJ73jtAhMEFP4yf+WQNe8BAZZe70EI= Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [95.163.41.68]) (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 C8614404481 for ; Thu, 9 Nov 2023 15:08:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C8614404481 Received: by smtp29.i.mail.ru with esmtpa (envelope-from ) id 1r13q4-00Gce8-2A; Thu, 09 Nov 2023 15:08:49 +0300 Message-ID: <4b9160db-32f4-4edd-ae1c-39a7cf004216@tarantool.org> Date: Thu, 9 Nov 2023 15:08:48 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Maksim Kokryashkin , tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, m.kokryashkin@tarantool.org References: <20231107210616.53138-1-max.kokryashkin@gmail.com> <20231107210616.53138-3-max.kokryashkin@gmail.com> In-Reply-To: <20231107210616.53138-3-max.kokryashkin@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9C2A6B03AB739174C6C1832769EA9286E0D6FE4A60DB83BBE00894C459B0CD1B94FEFB205C2C1B9DE7B15ABD43C1C1079ABF1E31C62EE0BEBB7E140D37D564E50 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78E8764B5BC580342EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C1CDCB5E4A85220F8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D844FFE4FD2DA8AD2D1319727E7E4CCF6E117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18BDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE26055571C92BF10FB341D7040ADD27A2D8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE32D01283D1ACF37BA2D242C3BD2E3F4C6C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947C062BEEFFB5F8EA3E2E808ACE2090B5E1725E5C173C3A84C317B107DEF921CE79089D37D7C0E48F6C8AA50765F7900637F0A05763E19AB7F2EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5018256451311804257FDBDE18DCDD3605A203102514DED5DF87CCE6106E1FC07E67D4AC08A07B9B0FE4D9CDE3FF759CFCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF05EA834C78ED7321ACB08A5C20098A85A0376906C2705A33D822CAA4ED3FDF93F02FE508BB13AAFBD0DB820CB2E38D8BCF0F042655AB1065467EA7AF0F3DC845A74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojKdAcnY08CHJqtQqHvJrpRg== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769FBBBEB92697F843F2EBC4CC022C40B3C7962F9E9328436E1EBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v2 2/2] Fix last commit. 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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Max Thanks for the patch! LGTM On 11/8/23 00:06, Maksim Kokryashkin wrote: > From: Mike Pall > > Reported by PluMGMK. > > (cherry-picked from commit 224129a8e64bfa219d35cd03055bf03952f167f6) > > The `_VMEVENTS` table, where the error handler for GC finalizers > is set, was not cleared from the stack after the initialization. > This commit adds stack cleanup. > > Maxim Kokryashkin: > * added the description and the test for the problem > > Part of tarantool/tarantool#9145 > --- > src/lib_aux.c | 2 ++ > ...91-fix-finalizer-error-handler-init.test.c | 30 +++++++++++++++++++ > 2 files changed, 32 insertions(+) > create mode 100644 test/tarantool-c-tests/lj-991-fix-finalizer-error-handler-init.test.c > > diff --git a/src/lib_aux.c b/src/lib_aux.c > index d532a12f..ecdc67f9 100644 > --- a/src/lib_aux.c > +++ b/src/lib_aux.c > @@ -352,6 +352,7 @@ LUALIB_API lua_State *luaL_newstate(void) > lua_pushcfunction(L, error_finalizer); > lua_rawseti(L, -2, VMEVENT_HASH(LJ_VMEVENT_ERRFIN)); > G(L)->vmevmask = VMEVENT_MASK(LJ_VMEVENT_ERRFIN); > + L->top--; > #endif > } > return L; > @@ -378,6 +379,7 @@ LUALIB_API lua_State *luaL_newstate(void) > lua_pushcfunction(L, error_finalizer); > lua_rawseti(L, -2, VMEVENT_HASH(LJ_VMEVENT_ERRFIN)); > G(L)->vmevmask = VMEVENT_MASK(LJ_VMEVENT_ERRFIN); > + L->top--; > #endif > } > return L; > diff --git a/test/tarantool-c-tests/lj-991-fix-finalizer-error-handler-init.test.c b/test/tarantool-c-tests/lj-991-fix-finalizer-error-handler-init.test.c > new file mode 100644 > index 00000000..49befc29 > --- /dev/null > +++ b/test/tarantool-c-tests/lj-991-fix-finalizer-error-handler-init.test.c > @@ -0,0 +1,30 @@ > +#include "lua.h" > +#include "test.h" > +#include "utils.h" > + > +/* > + * This test demonstrates an uncleared Lua stack after the > + * initialization of the error handler for GC finalizers. > + * See https://github.com/luajit/luajit/issues/991 for > + * details. > + */ > + > +static int stack_is_clean(void *test_state) > +{ > + lua_State *L = test_state; > + assert_true(lua_gettop(L) == 0); > + return TEST_EXIT_SUCCESS; > +} > + > +int main(void) > +{ > + lua_State *L = utils_lua_init(); > + > + const struct test_unit tgroup[] = { > + test_unit_def(stack_is_clean) > + }; > + > + const int test_result = test_run_group(tgroup, L); > + utils_lua_close(L); > + return test_result; > +}