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 93CA85EFBAB; Thu, 7 Sep 2023 11:08:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 93CA85EFBAB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1694074082; bh=9LpQkQGu5BqFvFfH4e9Yp5KqRIrJuLqxsdXElDidk+o=; 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=yb6bb9ZWU8NvnzjfOfB6sauxhjWoo51kDLSiOK3kFVjOHWFOwQIFE33vktilZ1KLV Xex/97fUVy3VRI9iVgHy4CqTQsmoMr0Z/9SAT+NjwKd4RxcerPKPKYdM4tdec2ZTHm UB82oC+bbN5fMTxXVr0ufeozGh8s8mK1PApXbQDQ= Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [95.163.41.100]) (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 B6D0C5A5F77 for ; Thu, 7 Sep 2023 11:08:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B6D0C5A5F77 Received: by smtp63.i.mail.ru with esmtpa (envelope-from ) id 1qeA3T-00H0NX-0h; Thu, 07 Sep 2023 11:07:59 +0300 Message-ID: Date: Thu, 7 Sep 2023 11:07:58 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Content-Language: en-US To: Maxim Kokryashkin , tarantool-patches@dev.tarantool.org, skaplun@tarantool.org References: <1adf54160bcf5f2383f875fbc5fb0b903f68c8fc.1693910172.git.m.kokryashkin@tarantool.org> In-Reply-To: <1adf54160bcf5f2383f875fbc5fb0b903f68c8fc.1693910172.git.m.kokryashkin@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD96E142CFC92DB15CD2D825373A67B852D03EA56D9B66A64FA182A05F538085040975F7CEA3535A187A852D09F91DE1133C3371DD3D064981AEF29AADE048392F1 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72424932217190DC2EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378F6D32451C4A3CAA8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8E90920699681578F258BB4BEEC62DE73117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC0E6D796F508274C4A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18E5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE9647ADFADE5905B13D5BA627BF9F2FCFD8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3632EDEA9CD5989A3C0837EA9F3D19764C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947C2FFDA4F57982C5F42E808ACE2090B5E1725E5C173C3A84C317B107DEF921CE79089D37D7C0E48F6C8AA50765F790063752464DD08821749FEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A54EDE0950ED060B4051BB6E3B2829C77CE8C381C0FDC58A04F87CCE6106E1FC07E67D4AC08A07B9B04B3849D6E5CCBAFDBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF0E29A283A15BEAC9A092EA5A8C21E6898F8FC75C8A7E638536F75162D3567E6DBF40353A1B84A4508757DCF1EFBC4EA78B93E60111D276C158888DBE4BC99902A74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojAl6H1x/OglKbwU3/oaTHLQ== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769D997F07448459FD6A852D09F91DE113314D23FB96A9F340BEBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] Fix frame for on-trace out-of-memory error. 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 see my comments below On 9/5/23 13:39, Maxim Kokryashkin wrote: > Reported by ruidong007. > > (cherry-picked from commit 2d8300c1944f3a62c10f0829e9b7847c5a6f0482) > > When an on-trace OOM error is triggered from a frame that is > child in regard to `jit_base`, and `L->base` is not updated > correspondingly (FUNCC, for example), it is possible to > encounter an inconsistent Lua stack in the error handler. > > This patch adds a fixup for OOM errors on the trace that always > sets the Lua stack base to `jit_base`, so the stack is > now consistent. > > Part of tarantool/tarantool#8825 > --- > +local testoomframe = require('testoomframe') > + > +local anchor_memory = {} -- luacheck: no unused > +local function eatchunks(size) > + while true do > + anchor_memory[ffi.new('char[?]', size)] = 1 Why ffi.new() is a key, not a value? > + end > +end > + > +pcall(eatchunks, 512 * 1024 * 1024) Why exactly this size is used? > + > +local anchor = {} > +local function extra_frame(val) > + table.insert(anchor, val) > +end > + > +local function chomp() > + while true do > + extra_frame(testoomframe.allocate_userdata()) > + end > +end > + > +local st, err = pcall(chomp) > +test:ok(st == false, 'on-trace error handled successfully') > +test:like(err, 'not enough memory', 'error is OOM') > +test:done(true) > diff --git a/test/tarantool-tests/lj-1004-oom-error-frame/CMakeLists.txt b/test/tarantool-tests/lj-1004-oom-error-frame/CMakeLists.txt > new file mode 100644 > index 00000000..3bca5df8 > --- /dev/null > +++ b/test/tarantool-tests/lj-1004-oom-error-frame/CMakeLists.txt > @@ -0,0 +1 @@ > +BuildTestCLib(testoomframe testoomframe.c) > diff --git a/test/tarantool-tests/lj-1004-oom-error-frame/testoomframe.c b/test/tarantool-tests/lj-1004-oom-error-frame/testoomframe.c > new file mode 100644 > index 00000000..a54eac63 > --- /dev/null > +++ b/test/tarantool-tests/lj-1004-oom-error-frame/testoomframe.c > @@ -0,0 +1,17 @@ > +#include > +#include Test uses headers provided by systems instead of headers provided by LuaJIT-under-test. It is expected? --- a/test/tarantool-tests/lj-1004-oom-error-frame/testoomframe.c +++ b/test/tarantool-tests/lj-1004-oom-error-frame/testoomframe.c @@ -1,5 +1,5 @@ -#include -#include +#include "lua.h" +#include "lauxlib.h"  static int allocate_userdata(lua_State *L) {         lua_newuserdata(L, 1); > + > +static int allocate_userdata(lua_State *L) { > + lua_newuserdata(L, 1); > + return 1; > +} > + > +static const struct luaL_Reg testoomframe[] = { > + {"allocate_userdata", allocate_userdata}, > + {NULL, NULL} > +}; > + > +LUA_API int luaopen_testoomframe(lua_State *L) { > + luaL_register(L, "testoomframe", testoomframe); > + return 1; > +}