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 63C0E6FA3A5; Fri, 24 Nov 2023 15:34:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 63C0E6FA3A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1700829276; bh=6z1s/u3mRpIsq57aZigfcMsE2lQmOU0jc3GQMS+Y5Dg=; 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=NDwSGhiHAMhU2F3K5H8jOQfxXRcy98cdUQkOyS1eBo7UmWi1OpS1S7bJwvinQxVod MZKIrqkddhQxBPAqwoWfudg+V3M12LqzSS4SCZmDmb1RO2uTHk8Sgfw8MfXI1/RM+R bU82V4PhStlUizjfvbjj3IJvl5gAzE1f4v0nkllU= 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 0D3C66FA3A5 for ; Fri, 24 Nov 2023 15:34:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0D3C66FA3A5 Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1r6VOD-000nrE-0o; Fri, 24 Nov 2023 15:34:33 +0300 Message-ID: <5e448fb8-91d4-40a3-b9ca-8d08d307467c@tarantool.org> Date: Fri, 24 Nov 2023 15:34:32 +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: <20231122143534.11330-1-max.kokryashkin@gmail.com> <20231122143534.11330-4-max.kokryashkin@gmail.com> In-Reply-To: <20231122143534.11330-4-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: 4F1203BC0FB41BD91D46036009216274E71E16B70556B6C138888C2D11A96F08182A05F53808504027D15305B44D62F45A78FDB47DD46159C8114815E62C2581F4CFA955E43D92B6 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78CB87876C5D626D4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377F497DA9C8A5F4D48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D806CC92AC5366A30B2C185BB43D86CF47117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD1828451B159A507268D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE26055571C92BF10FB1CA5D0BF4193578D8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE32D01283D1ACF37BA6E0066C2D8992A16C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947C062BEEFFB5F8EA3E2E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F9FFED5BD9FB417555E1C53F199C2BB95B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A52CD01C7A638B4B28D95E5C330800C6FFCAE5EE17E875C088F87CCE6106E1FC07E67D4AC08A07B9B0A6C7FFFE744CA7FBCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF6FB23DC4DBDD71C06D8E41D08E2D48AB078B1348D876895BB2CA2DF508071D7242BBF92C36119C856E159192F517E6719F7A173E762D1AEC9FAACD90E3DB64B1A74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojXb+1cQU8cANoPLUg6AAHgA== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769D513D0E4AC2B34875A78FDB47DD4615938066306E4938E9FEBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v3 3/3] Follow-up fix for stack overflow handling cleanup. 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" Hello, Max added testcase is passed with reverted patch Sergey On 11/22/23 17:35, Maksim Kokryashkin wrote: > From: Mike Pall > > (cherry-picked from commit aa6b15c1a8922848bd6f596ba384824ca3fe0f5f) > > The stack overflow error is thrown in `lj_state_growstack` only > if the coroutine status is `OK`, however, stack overflow can > happen on a yielded coroutine too. This patch fixes the condition > for status, so now the error thrown on yielded coroutines too. > > Maxim Kokryashkin: > * added the description and the test for the patch > > Part of tarantool/tarantool#9145 > --- > src/lj_state.c | 2 +- > .../lj-962-premature-stack-overflow.test.c | 23 +++++++++++++++++++ > 2 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/src/lj_state.c b/src/lj_state.c > index d8a5134c..01d4901a 100644 > --- a/src/lj_state.c > +++ b/src/lj_state.c > @@ -126,7 +126,7 @@ void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) > if (L->stacksize > LJ_STACK_MAXEX) > lj_err_throw(L, LUA_ERRERR); /* Does not invoke an error handler. */ > /* 1. We are _at_ the limit after the last growth. */ > - if (!L->status) { /* 2. Throw 'stack overflow'. */ > + if (L->status < LUA_ERRRUN) { /* 2. Throw 'stack overflow'. */ > L->status = LUA_ERRRUN; /* Prevent ending here again for pushed msg. */ > lj_err_msg(L, LJ_ERR_STKOV); /* May invoke an error handler. */ > } > diff --git a/test/tarantool-c-tests/lj-962-premature-stack-overflow.test.c b/test/tarantool-c-tests/lj-962-premature-stack-overflow.test.c > index 12cb9004..461e0ccc 100644 > --- a/test/tarantool-c-tests/lj-962-premature-stack-overflow.test.c > +++ b/test/tarantool-c-tests/lj-962-premature-stack-overflow.test.c > @@ -24,6 +24,20 @@ static int fill_stack(lua_State *L) > return 0; > } > > +static int immediate_yield(lua_State *L) > +{ > + return lua_yield(L, 0); > +} > + > +static int overflow_suspended_coro(lua_State *L) > +{ > + lua_State *newL = lua_newthread(L); > + lua_pushcfunction(newL, immediate_yield); > + lua_resume(newL, 0); > + fill_stack(newL); > + return 0; > +} > + > static int premature_stackoverflow(void *test_state) > { > lua_State *L = test_state; > @@ -50,12 +64,21 @@ static int stackoverflow_during_stackoverflow(void *test_state) > return TEST_EXIT_SUCCESS; > } > > +static int stackoverflow_on_suspended_coro(void *test_state) > +{ > + lua_State *L = test_state; > + int status = lua_cpcall(L, overflow_suspended_coro, NULL); > + assert_true(status == LUA_ERRRUN); > + return TEST_EXIT_SUCCESS; > +} > + > int main(void) > { > lua_State *L = utils_lua_init(); > const struct test_unit tgroup[] = { > test_unit_def(premature_stackoverflow), > test_unit_def(stackoverflow_during_stackoverflow), > + test_unit_def(stackoverflow_on_suspended_coro), > }; > const int test_result = test_run_group(tgroup, L); > utils_lua_close(L);