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 C30706E7183; Mon, 20 Nov 2023 15:04:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C30706E7183 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1700481883; bh=+oshRqOYVLovRiqRGDX0j8vxzDQxRTjL/fbKsuQA/eg=; 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=E2JmB7CaaarUs8eyhpzSTZsqZ5NTzPK8Zy7EssOdHLGIJ6G+T1+j3aWqVig028CgN 9113hZ6OoGmJDUJcZLoXpYLyqfYNLgqmsV0RPGcSCz789Gy9X+OuRsvenvdf+PmLX+ ZUnwHKVqeFkWgAB25UXs7AOUcIIP+PJ9O/N3D++U= Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [95.163.41.96]) (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 88A6D6E6CBD for ; Mon, 20 Nov 2023 15:04:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 88A6D6E6CBD Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1r5316-003ZoN-2d; Mon, 20 Nov 2023 15:04:41 +0300 Date: Mon, 20 Nov 2023 15:00:08 +0300 To: Maksim Kokryashkin Message-ID: References: <20231117234116.60037-1-max.kokryashkin@gmail.com> <20231117234116.60037-2-max.kokryashkin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231117234116.60037-2-max.kokryashkin@gmail.com> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9BE2AA157F0467848E5078B8A6730C0A65F7BE7DDFC63FF0D182A05F5380850404C228DA9ACA6FE27699EFEC9CAB4FE149A057C4BA3C065C38792C5AF77CCE8E05A4CDAB2B49B3CAD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D6964C9E324ABA58EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378CCCB41504E044EE8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8D709EE4F52C67868B4B1D2A29314C18B117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18CB629EEF1311BF91D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE0AC5B80A05675ACDC3123C4324A5CF10D8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3D56D36E97F3F038C6E0066C2D8992A16C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CD2DCF9CF1F528DBC2E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F0A35B161A8BF67C142539A7722CA490CB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A56EB83E10756EF2906C8A16F3100CB36FAD2112B2AFC46B8CF87CCE6106E1FC07E67D4AC08A07B9B0B355ED1E20F5346ACB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFF9514FB5389871E94E1A8E3D09FB1677DC9CCEEB594AE8604ED5365EC0EA12C18FF2D56E53A0872888AD3775A6B0C834196A28D7A91BED7A1668487DC3B39E15A74DFFEFA5DC0E7F02C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmRIjd71J0y3nS1/LkIpJQQ== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A76933F91F9CC39F1ACA9A057C4BA3C065C3C9F871340C5A6C40DEDBA653FF35249392D99EB8CC7091A70E183A470755BFD208F19895AA18418972D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/3] Improve error reporting on stack overflow. 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 patch! Please, consider my comments below. On 18.11.23, Maksim Kokryashkin wrote: > From: Mike Pall > > Thanks to Nicolas Lebedenco. > > (cherry-picked from commit 8135de2a0204e6acd92b231131c4a1e0be03ac1c) > > The `lj_state_growstack` doesn't account for a potential error > handler invocation by xpcall, which may lead to the second error > while handling a stack overflow, resulting in a misleading error > "error in error handling", while the real issue is a stack > overflow. This patch addresses this issue by fixing the condition > at which stack overflow errors are thrown. Now it's thrown if the > stack size is at least at the limit, instead of when it is over > the limit. > > This commit also disables the second test from > `lj-603-err-snap-restore`, since after this patch and the two > follow-ups for it, there is no such amount of stack slots with > which the test works the way it should. > > Maxim Kokryashkin: > * added the description and the test for the problem > > Part of tarantool/tarantool#9145 > --- > src/lj_state.c | 2 +- > .../lj-603-err-snap-restore.test.lua | 1 + > .../lj-962-stack-overflow-report.test.lua | 24 +++++++++++++++++++ > 3 files changed, 26 insertions(+), 1 deletion(-) > create mode 100644 test/tarantool-tests/lj-962-stack-overflow-report.test.lua > > diff --git a/src/lj_state.c b/src/lj_state.c > index 684336d5..76153bad 100644 > --- a/src/lj_state.c > +++ b/src/lj_state.c > diff --git a/test/tarantool-tests/lj-603-err-snap-restore.test.lua b/test/tarantool-tests/lj-603-err-snap-restore.test.lua > index 96ebf92c..f5c8474f 100644 > --- a/test/tarantool-tests/lj-603-err-snap-restore.test.lua > +++ b/test/tarantool-tests/lj-603-err-snap-restore.test.lua > diff --git a/test/tarantool-tests/lj-962-stack-overflow-report.test.lua b/test/tarantool-tests/lj-962-stack-overflow-report.test.lua > new file mode 100644 > index 00000000..bcddff01 > --- /dev/null > +++ b/test/tarantool-tests/lj-962-stack-overflow-report.test.lua > @@ -0,0 +1,24 @@ > +local tap = require('tap') > +local test = tap.test('lj-962-stack-overflow-report') > + > +test:plan(2) > + > +-- luacheck: no unused > +local _, _, _, _, _, _, _ I am very nervous, when I see these `_, _, ...` guys again. I suggest introducing helper to fill up the necessary slots with correponding comments. Also, this test passes on the GC64/non-GC64 build on the current master branch. > +local error_message > +local handler_is_called = false > +local function errfunc(err) > + -- luacheck: no unused > + local _ > + error_message = err > + handler_is_called = true > +end > + > +local function recursive_f() > + recursive_f() > +end > +xpcall(recursive_f, errfunc) > + > +test:ok(handler_is_called, 'error handler was able to use a stack slot') Typo: s/was/is/ Minor: Also maybe it's worth being more descriptive "an additional stack slot". > +test:like(error_message, '.+stack overflow$', 'stack overflow happened') Minor: I suggest dropping `.+` at the start of the pattern since it doesn't matter. NB: the `$` is important to distinguish `STKOV` and `STKOVM`. > +test:done(true) > -- > 2.39.3 (Apple Git-145) > -- Best regards, Sergey Kaplun