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 00EE913E954C; Fri, 6 Jun 2025 16:48:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 00EE913E954C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1749217728; bh=2yInS0DFpwRoiY1R+qlIIAurQZBVuW417HbHGlQLpzI=; 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=pFwlSTYI/az1jji4EM1v4gUNn+UKeF+H/rLzUfGSgsAusHb/Ik4NiYG1l/0UUuGT3 bfzUWsyKKF8bgtbb7ghb+pT8/TNnrzkh7vTgfjvChARRo/tIRZvG65Bi5kS3U0PuQP 6qU6JVzLiLQDfSmyTMVv4L9OTuh23qEZUukyCJ5M= Received: from send196.i.mail.ru (send196.i.mail.ru [95.163.59.35]) (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 3436313E9541 for ; Fri, 6 Jun 2025 16:48:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3436313E9541 Received: by exim-smtp-567cc788d4-mtjgw with esmtpa (envelope-from ) id 1uNXR7-00000000L64-0Kir; Fri, 06 Jun 2025 16:48:45 +0300 Date: Fri, 6 Jun 2025 16:48:49 +0300 To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Message-ID: References: <20250425134215.8184-1-skaplun@tarantool.org> <4c846b1b-e15e-49a8-86a7-da857c7a5a5b@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: 4F1203BC0FB41BD95E97EA1894635BC3D6FCFE98DF17D20F3CDD99DBF903E6E8182A05F53808504079E505C34B542F943DE06ABAFEAF6705F58FB0E8D09C76C32B9C6D42F51226CA2EB2DA79D556EF8B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7922E451CE6E839B1EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB5533756680FD86C7FE90CFE5F4280FC474107625F453473281B1929CCCBBBA86CE1119DB389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B64854413538E1713FCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7D151390FFDBF6399731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5132357C6D92568625002B1117B3ED6969F5EF346BAE876A16E5F408120975D33823CB91A9FED034534781492E4B8EEADB73CFAAED92B6E13BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D34C75F910DBB8BE8980C7AC383685AAE597FF01EE1F999745A2427C3C2DB256C07148F14BA4711B8701D7E09C32AA3244CC03FCF495056EB6777DD89D51EBB7742B697463F214080A8EA455F16B58544A2E30DDF7C44BCB90DA5AE236DF995FB59829709634694AABAED6A17656DB59BCAD427812AF56FC65B X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVSykAyseJQ6/k+7m489eu+A= X-DA7885C5: FBF99D8A0C7BFC3DF255D290C0D534F937CA10770CF04B67154FC18E5BD460086EBAE25D5754896F5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393FE9E42A757851DB6779FD6132AED99BC33AC15A4898F03F167445521A3B4C4DBE49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Rework stack overflow handling. 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" Sergey, On 06.06.25, Sergey Bronnikov wrote: > Hello, > > LGTM with a comment below. > > Sergey > > On 6/6/25 16:40, Sergey Kaplun wrote: > > > > >>> diff --git a/test/LuaJIT-tests/lang/stackov.lua b/test/LuaJIT-tests/lang/stackov.lua > >>> index 8afa86b4..b052ad80 100644 > >>> --- a/test/LuaJIT-tests/lang/stackov.lua > >>> +++ b/test/LuaJIT-tests/lang/stackov.lua > >> I don't get why we need this change. With reverted patch this test is > >> passed. > > With reverted -- yes. But after reworking the stack overflow handling, > > it is possible that there is no place on the stack to call the error > > handler (in that case, `debug.traceback`). Since this thing looks like > > implementation-defined behaviour, I prefer to make the test less strict. > > > Please add a message to the test or/and to the commit message. Added the note to the commit message. Now it looks like the following: | Rework stack overflow handling. | | Reported by pwnhacker0x18. Fixed by Peter Cawley. | | (cherry picked from commit defe61a56751a0db5f00ff3ab7b8f45436ba74c8) | | In case of the Lua stack overflow error, LuaJIT restores the `L->top` | value and pushes the error message above. It is possible that the | restored value is greater than `L->maxstack`, so pushing the error | message causes dirty write out-of-bounds. | | This patch prevents it by overwriting stack overflow handling machinery. | Now, in the aforementioned case, the last frame is replaced with a dummy | frame to avoid dirty writes. In some cases, there may not be enough | space on the stack to invoke the error handler. See the related changes | in the . | | Sergey Kaplun: | * added the description and the test for the problem | | Part of tarantool/tarantool#11278 > >>> @@ -31,13 +31,17 @@ end > >>> do --- Base test. > >>> local err, s = xpcall(f, debug.traceback) > >>> assert(err == false) > >>> - test_error_msg(f, s) > >>> + -- There is no place on the stack to invoke the handler. > >>> + -- Just test the error reason. > >>> + assert(string.match(s, "stack overflow")) > >>> end > >>> > >>> do --- Stack overflow with non-empty arg list. > >>> local err, s = xpcall(g, debug.traceback, 1) > >>> assert(err == false) > >>> - test_error_msg(g, s) > >>> + -- There is no place on the stack to invoke the handler. > >>> + -- Just test the error reason. > >>> + assert(string.match(s, "stack overflow")) > >>> end > >>> > >>> do --- Vararg tail call with non-empty arg list. +slow > > > > -- Best regards, Sergey Kaplun