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 59EEB51BE6C; Sat, 1 Jul 2023 14:52:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 59EEB51BE6C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1688212361; bh=rMMZYUF5DfWfA44Ce46YCACNx/eop8j0RaIFAJyKrhk=; 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=Jm1K3UnsCyjXtGLGVDV3sAmKG3cnbMrR7D2jee6H7lcOaG+pwf56oEL0LzlpCbDjX fwmyXnGfLiJJVv3GGUBtDuJh0HdF+FYVB1wEAOTTBW78RIiTpS1pj2tsNior3/IRGZ d0KSpqRN+mirK3B5Zo78owbEN3byhWPdhodmjgY0= Received: from smtp47.i.mail.ru (smtp47.i.mail.ru [95.163.41.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C4AF24AF082 for ; Sat, 1 Jul 2023 14:52:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C4AF24AF082 Received: by smtp47.i.mail.ru with esmtpa (envelope-from ) id 1qFZ9a-00HK7n-O7; Sat, 01 Jul 2023 14:52:39 +0300 Date: Sat, 1 Jul 2023 11:44:16 +0000 To: Sergey Kaplun Message-ID: References: <56e13650b2f5d7536c96c01bbbee3d4c42eedf67.1687439049.git.skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <56e13650b2f5d7536c96c01bbbee3d4c42eedf67.1687439049.git.skaplun@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9D327C87852EB66D3080F4C810759D0F811E72B7AA1AF68FA182A05F5380850404C228DA9ACA6FE27CE3468F3C12D6F76F8AF2947D2A1FB6873DCCDE0D2ABF06E859B1E80A8A8B8F1 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A8325FA649D0A450EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006376EC5B14D896A2D978638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D844827E874C897CC11AD371774FC69860117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B6CE7A4E25BAF3B969FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7F40BB13C7F5665BED32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C06E8EC05BDE27CD4ACD04E86FAF290E2DB606B96278B59C421DD303D21008E29813377AFFFEAFD269176DF2183F8FC7C0FE3A47D6FA29121068655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C837C4FEFBD186071C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5A437CA92457FEEBCF68C9C2C9FA76A6BB272D0530C1AFEA6F87CCE6106E1FC07E67D4AC08A07B9B01F9513A7CA91E555CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D34431D0341F6B74DD3809872F9703044DD42F76018C65B4CA8BE0E73EB854CF1EC1AF2644A259218AE1D7E09C32AA3244C00FDBE0243E4A32F352A4A709399436AF94338140B71B8EEBAD658CF5C8AB4025DA084F8E80FEBD376A4ED3E9341DC2FCD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMJXPKWcdXi4b5TXUMLaDGQ== X-Mailru-Sender: 2FEBA92C8E508479FE7B9A1DF348D5311BD119F4A27FFF6687EA6BB1E90895E885C4CE46B61099832326FE6F2A341ACE0FB9F97486540B4CD9E8847AB8CFED4D9ABF8A61C016C2CFB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] Fix lua_yield() from C hook. 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, Thanks for the patch! LGTM, considering the fixes for the comments left by Max. On 22.06.23, Sergey Kaplun wrote: > From: Mike Pall > > Reported by Jason Carr. > > (cherry picked from commit dd5032ed844c56964347c7916db66b0eb11d8091) > > When we call `lua_yield()` from the C hook the additional continuation > frame is added. This frame contains a continuation function, PC where we > should return, thread GC object to continue, and this frame type and > size (see details in ). For non-GC64 mode, when we set > the GC thread on the Lua stack, stack top isn't incremented, so the GC > thread overwrites the PC to return. For the GC64 mode the increment is > missing before setting frame type and size. > > This patches fixes the behaviour by adding missing slot incrementing. > Also, it hardens the conditions of using `lj_err_throw()`, according the > availability of external unwinder. > > The behaviour for the GC64 mode is still wrong due to miscalculation of > the slot of the GC thread object. This will be fixed in the next > commit. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#8516 > --- > src/lj_api.c | 5 +- > .../fix-yield-c-hook-script.lua | 19 +++++++ > .../tarantool-c-tests/fix-yield-c-hook.test.c | 53 +++++++++++++++++++ > 3 files changed, 75 insertions(+), 2 deletions(-) > create mode 100644 test/tarantool-c-tests/fix-yield-c-hook-script.lua > create mode 100644 test/tarantool-c-tests/fix-yield-c-hook.test.c > > -- > 2.34.1 > -- Best regards, IM