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 66A1D63B673; Fri, 8 Sep 2023 16:18:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 66A1D63B673 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1694179134; bh=zEs+52yTewnkCzsEmT1Qva0GbRyahj1RxwbR4Ii4JaE=; 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=KgkL2WQQRkENlhvPGs9Fhw9Jhv45rX0WNJMp8Hl6GNHeiE7pd+LSJ9ZYvwgas4OFv 9/D7pomWHcBdJ31p7zz33rqssauQm9zKHqajX2dK/XJQ4nxNmzXohfSbeSyhF1izTr 4BuaThEZDVZQw6DTacjyFvzSaNrnB/tnxY3DuDHM= Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [95.163.41.81]) (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 64C0863B673 for ; Fri, 8 Sep 2023 16:18:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 64C0863B673 Received: by smtp40.i.mail.ru with esmtpa (envelope-from ) id 1qebNs-00DToL-2F; Fri, 08 Sep 2023 16:18:53 +0300 Date: Fri, 8 Sep 2023 16:18:52 +0300 To: Sergey Bronnikov Message-ID: <67yxwvlqg25jcdc5kfot73j54l7bsddcs22cht54cqlj32muca@ri5nczyzho6d> References: <1adf54160bcf5f2383f875fbc5fb0b903f68c8fc.1693910172.git.m.kokryashkin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailru-Src: smtp X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD96E142CFC92DB15CDBADBDDCFFE5033A370A9F145D9D5274F182A05F5380850407563504945FB06FA50C991ACA2B396DAA8B820BC697AA9BB2F2B12136656FA18 X-C1DE0DAB: 0D63561A33F958A583C6525050F710C2B16A3EB5FDD991DD108607684AAFBF29F87CCE6106E1FC07E67D4AC08A07B9B0AD0E433DBF1FBFA3CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0AD5177F0B940C8B66ECE892A7B2722663E91682638B966EB3F662256BEEFA9527FD544C1369C2CF1AF809BC92B1124462162E6D0779E794E3A4222BF4F4352EBDFF994E6EFF718F4C637FD76D11AF80A0DBAB56955701F3FF6BF97257961088A08EA455F16B58544A21C197AAF4D2E4732965026E5D17F6739C77C69D99B9914278E50E1F0597A6FD5CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojHV97et/Y5fzvgDADot/aPA== X-Mailru-Sender: 11C2EC085EDE56FA38FD4C59F7EFE4073C3EFBDD69B94332D0794D53337EC4A3C791B84A9425D507D51284F0FE6F529ABC7555A253F5B200DF104D74F62EE79D27EC13EC74F6107F4198E0F3ECE9B5443453F38A29522196 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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Cc: Maxim Kokryashkin , tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the review! See my answers below. > > +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? Its just a very common pattern in our tests, also I don't really want to manage a separate counter for the key. ffi.new() can be a value as well, no issue with that. > > > + end > > +end > > + > > +pcall(eatchunks, 512 * 1024 * 1024) > > Why exactly this size is used? It is empirically selected number, dropped a comment. > > > > + > > +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? Fixed, thanks. > > --- 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; > > +} Here is the diff with changes. Branch is force-psuhed. diff --git a/test/tarantool-tests/lj-1004-oom-error-frame.test.lua b/test/tarantool-tests/lj-1004-oom-error-frame.test.lua index b6b5a9f2..3be6b555 100644 --- a/test/tarantool-tests/lj-1004-oom-error-frame.test.lua +++ b/test/tarantool-tests/lj-1004-oom-error-frame.test.lua @@ -17,6 +17,9 @@ local function eatchunks(size) end end +-- The chunk size below is empirical. It is big enough, so the test +-- is not too long, yet small enough for the OOM frame issue to have +-- enough iterations in the second loop to trigger. pcall(eatchunks, 512 * 1024 * 1024) local anchor = {} diff --git a/test/tarantool-tests/lj-1004-oom-error-frame/testoomframe.c b/test/tarantool-tests/lj-1004-oom-error-frame/testoomframe.c index a54eac63..dbfe17db 100644 --- 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);