From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Maxim Kokryashkin <max.kokryashkin@gmail.com>, tarantool-patches@dev.tarantool.org, skaplun@tarantool.org Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] Fix frame for on-trace out-of-memory error. Date: Thu, 7 Sep 2023 11:07:58 +0300 [thread overview] Message-ID: <a2b6672f-e268-fcf7-03ee-c4e07c469175@tarantool.org> (raw) In-Reply-To: <1adf54160bcf5f2383f875fbc5fb0b903f68c8fc.1693910172.git.m.kokryashkin@tarantool.org> 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 > --- <snipped> > +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 <lua.h> > +#include <lauxlib.h> 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 <lua.h> -#include <lauxlib.h> +#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; > +}
next prev parent reply other threads:[~2023-09-07 8:08 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-05 10:39 [Tarantool-patches] [PATCH luajit 0/2] Fix frames for on trace errors Maxim Kokryashkin via Tarantool-patches 2023-09-05 10:39 ` [Tarantool-patches] [PATCH luajit 1/2] Fix frame for on-trace out-of-memory error Maxim Kokryashkin via Tarantool-patches 2023-09-07 8:07 ` Sergey Bronnikov via Tarantool-patches [this message] 2023-09-08 13:18 ` Maxim Kokryashkin via Tarantool-patches 2023-09-12 9:53 ` Sergey Bronnikov via Tarantool-patches 2023-09-11 8:04 ` Sergey Kaplun via Tarantool-patches 2023-09-11 11:52 ` Maxim Kokryashkin via Tarantool-patches 2023-09-05 10:39 ` [Tarantool-patches] [PATCH luajit 2/2] Fix frame for more types of on-trace error messages Maxim Kokryashkin via Tarantool-patches 2023-09-07 8:11 ` Sergey Bronnikov via Tarantool-patches 2023-09-07 8:56 ` Maxim Kokryashkin via Tarantool-patches 2023-09-07 10:06 ` Sergey Bronnikov via Tarantool-patches 2023-09-11 8:20 ` Sergey Kaplun via Tarantool-patches 2023-09-11 13:45 ` Maxim Kokryashkin via Tarantool-patches 2023-09-27 12:33 ` [Tarantool-patches] [PATCH luajit 0/2] Fix frames for on trace errors Igor Munkin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=a2b6672f-e268-fcf7-03ee-c4e07c469175@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=max.kokryashkin@gmail.com \ --cc=sergeyb@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit 1/2] Fix frame for on-trace out-of-memory error.' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox