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 B3991BA2F01; Thu, 13 Jun 2024 17:52:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B3991BA2F01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1718290354; bh=RK22bA4OmKG2viIOBBOVeKZEqbZgZSnayeBGYlXH08Q=; 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=Wberbjr3MDHfn87cQBeLz15Z+CnYQBUM4ITQ7JiPJv51mionxCQKKWwi3x1MxvQba BSZeygMvAxMhUY62ou1V6rS/d1wznLOUhnqp8jm7BXvbY+B7wCHELjYPBA3TtwkTaA kbf+DeXr3Od9iFv1Vu3ow8QiuBTF52lUkO13/K+8= Received: from smtp41.i.mail.ru (smtp41.i.mail.ru [95.163.41.64]) (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 F0FEEBA2F01 for ; Thu, 13 Jun 2024 17:52:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F0FEEBA2F01 Received: by smtp41.i.mail.ru with esmtpa (envelope-from ) id 1sHloW-0000000AUQk-0bJG; Thu, 13 Jun 2024 17:52:32 +0300 Content-Type: multipart/alternative; boundary="------------0RXcbQAT0j67R06Bs5UKE0Rd" Message-ID: <7bd8ffff-02c9-4c91-b12a-047a6ba707d4@tarantool.org> Date: Thu, 13 Jun 2024 17:52:31 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun References: <362ec5c556a9e9832726ec89978ef25ba865af41.1713773432.git.skaplun@tarantool.org> In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9AC8CA0B4439200FAAADCB0684E75543E0F6F500DBE411A6A00894C459B0CD1B9BF03473223D20BE08AC4418F69759E31B4EBF1959D44440C90619446C17DCE8874CA12CB93F4C0D9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE707BCAA832FAF0FF2C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE72C932D6B54DFB189EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B043BF0FB74779F3639AE557D13BC6163B5FA0BB5FB21F40F08C97D6BA82BBE82A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE70F3DDF2BBF19B93A9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3CF36E64A7E3F8E58117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CF0126D0C731CE4B33BA3038C0950A5D36C8A9BA7A39EFB766D91E3A1F190DE8FDBA3038C0950A5D36D5E8D9A59859A8B611F26D826E9156BB76E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C1156E5889A6D309143847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5D129F84E1178E5B35002B1117B3ED6961AC4031F6FE538F9219207EC0A953D2C823CB91A9FED034534781492E4B8EEAD3CCD70CEBBF18A22BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFD067D0D2687CD82FD937ECEA77FF4007390B74B246E45E3C93070C5E7FCA5C97192AF36DABE8584504A26A3878DC13308C555347F8997383192D8488D63E40F32F36422252A3B03E5F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojP/c/PTD82Am4ewuUh+kugw== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140BF03473223D20BE08AC4418F69759E316EF3A50A39A38E1B0152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v1 4/5] Handle all types of errors during trace stitching. 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 Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------0RXcbQAT0j67R06Bs5UKE0Rd Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Sergey thanks for the fixes and answers! See my answers below. On 13.06.2024 13:25, Sergey Kaplun wrote: > Hi, Sergey! > Thanks for the review! > Please consider my answers below. > > On 06.06.24, Sergey Bronnikov wrote: > --- /dev/null > +++ b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua > @@ -0,0 +1,46 @@ > +local tap = require('tap') > + > +-- Test file to demonstrate unbalanced Lua stack after instruction > +-- recording due to throwing an error at recording of a stitched > +-- function. > +-- See also:https://github.com/LuaJIT/LuaJIT/issues/1166. > + > +local test = tap.test('lj-1166-error-stitch-oom-snap-buff'):skipcond({ >> should a name in tap.test match to test file name? >> >> now it is not. > My mistake during copipasting. Fixed. Thanks! >>> + ['Test requires JIT enabled'] = not jit.status(), >>> + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', >>> +}) >>> + >>> +test:plan(1) >>> + >>> +local mockalloc = require('mockalloc') >>> + >>> +local function create_chunk(n_slots) >> I would add a comment like this: >> >> >> --- a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua >> +++ b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua >> @@ -14,6 +14,18 @@ test:plan(1) >> >>  local mockalloc = require('mockalloc') >> >> +-- Generate a Lua chunk like below: >> +-- local s1 >> +-- local s2 >> +-- ... >> +-- local sN >> +-- for i = 1, 2 do >> +--   s1 = i + 1 >> +--   s2 = i + 2 >> +--   ... >> +--   sN = i + N >> +--   math.modf(1) >> +-- end >>  local function create_chunk(n_slots) >>    local chunk = '' >>    for i = 1, n_slots do > Added, see the iterative patch below. Thanks! > >> >>> + local chunk = '' > > >>> + >>> +local mockalloc = require('mockalloc') >>> + >>> +local function create_chunk(n_conds) >> the same as above: please add a comment with an example of generated Lua >> chunk > Added, see the iterative patch below. > Thanks! > diff --git a/test/tarantool-tests/lj-1166-error-stitch-table-bump.test.lua b/test/tarantool-tests/lj-1166-error-stitch-table-bump.test.lua > new file mode 100644 > index 00000000..f2453bbe > --- /dev/null > +++ b/test/tarantool-tests/lj-1166-error-stitch-table-bump.test.lua >> this test is not failed after reverting patch > Do you build luajit with -DLUAJIT_ENABLE_TABLE_BUMP=ON? > > > My bad. With enabled option tests failed: The following tests FAILED:         127 - test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua (SEGFAULT)         128 - test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua (SEGFAULT)         129 - test/tarantool-tests/lj-1166-error-stitch-table-bump.test.lua (SEGFAULT) Errors while running CTest >>> diff --git a/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c b/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c >>> new file mode 100644 >>> index 00000000..d6d3492e >>> --- /dev/null >>> +++ b/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c >>> @@ -0,0 +1,51 @@ > > >>> + >>> +/* Function to be used instead of the default allocator. */ >>> +static void *mock_allocf(void *ud, void *ptr, size_t osize, size_t nsize) >>> +{ >>> + assert(old_allocf != NULL); >>> + /* >>> + * Check the specific reallocation related to the IR >>> + * buffer or the snapshot buffer. >>> + */ >>> + if (osize * 2 == nsize) >>> + return NULL; >>> + return old_allocf(ud, ptr, osize, nsize); >>> +} >>> + >>> +static int mock(lua_State *L) >> >> It is actually not a test mock. >> >> According to definition [1] test mock imitate a behavior of a real object. >> >> Your memory allocator behaves as a real allocator, but in some cases it >> will return >> >> a NULL instead of memory address. What if we rename "mock" to "allocator >> with fault injection"? > I renamed `mock_allocf` to `allocf_with_injection()` to avoid > confusing. > > =================================================================== > diff --git a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua > index cf3ab0f5..eb229a5c 100644 > --- a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua > +++ b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua > @@ -5,7 +5,7 @@ local tap = require('tap') > -- function. > -- See also:https://github.com/LuaJIT/LuaJIT/issues/1166. > > -local test = tap.test('lj-1166-error-stitch-oom-snap-buff'):skipcond({ > +local test = tap.test('lj-1166-error-stitch-oom-ir-buff'):skipcond({ > ['Test requires JIT enabled'] = not jit.status(), > ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', > }) > @@ -22,6 +22,16 @@ jit.flush() > > test:plan(2) > > +-- Generate the following Lua chunk: > +-- local s1 > +-- ... > +-- local sN > +-- for i = 1, 2 do > +--   s1 = i + 1 > +--   ... > +--   sN = i + N > +--   math.modf(1) > +-- end > local function create_chunk(n_slots) > local chunk = '' > for i = 1, n_slots do > diff --git a/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua b/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua > index 8bbdd96b..8ae26386 100644 > --- a/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua > +++ b/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua > @@ -20,6 +20,13 @@ jit.flush() > > test:plan(2) > > +-- Generate the following Lua chunk: > +-- for i = 1, 2 do > +--   if i < 1 then end > +--   ... > +--   if i < N then end > +--   math.modf(1) > +-- end > local function create_chunk(n_conds) > local chunk = '' > chunk = chunk .. 'for i = 1, 2 do\n' > diff --git a/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c b/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c > index d6d3492e..19d32f8b 100644 > --- a/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c > +++ b/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c > @@ -8,7 +8,8 @@ static lua_Alloc old_allocf = NULL; > static void *old_alloc_state = NULL; > > /* Function to be used instead of the default allocator. */ > -static void *mock_allocf(void *ud, void *ptr, size_t osize, size_t nsize) > +static void *allocf_with_injection(void *ud, void *ptr, size_t osize, > + size_t nsize) > { > assert(old_allocf != NULL); > /* > @@ -24,14 +25,14 @@ static int mock(lua_State *L) > { > assert(old_allocf == NULL); > old_allocf = lua_getallocf(L, &old_alloc_state); > - lua_setallocf(L, mock_allocf, old_alloc_state); > + lua_setallocf(L, allocf_with_injection, old_alloc_state); > return 0; > } > > static int unmock(lua_State *L) > { > assert(old_allocf != NULL); > - assert(old_allocf != mock_allocf); > + assert(old_allocf != allocf_with_injection); > lua_setallocf(L, old_allocf, old_alloc_state); > old_allocf = NULL; > old_alloc_state = NULL; > =================================================================== > Filename and other variables still use prefix "mock": [0] ~/sources/MRG/tarantool/third_party/luajit$ grep -R mock test test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua:local mockalloc = require('mockalloc') test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua:mockalloc.mock() test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua:mockalloc.unmock() test/tarantool-tests/CMakeLists.txt:# Some tests use `LD_PRELOAD` to mock system calls (like test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua:local mockalloc = require('mockalloc') test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua:mockalloc.mock() test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua:mockalloc.unmock() test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:static int mock(lua_State *L) test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:static int unmock(lua_State *L) test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:static const struct luaL_Reg mockalloc[] = { test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:  {"mock", mock}, test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:  {"unmock", unmock}, test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:LUA_API int luaopen_mockalloc(lua_State *L) test/tarantool-tests/lj-1166-error-stitch/mockalloc.c: luaL_register(L, "mockalloc", mockalloc); test/tarantool-tests/lj-1166-error-stitch/CMakeLists.txt:BuildTestCLib(mockalloc mockalloc.c) have you left it intentionally? >> >> 1.https://www.martinfowler.com/articles/mocksArentStubs.html >> >>> +{ > > >>> diff --git a/test/tarantool-tests/lj-720-errors-before-stitch.test.lua b/test/tarantool-tests/lj-720-errors-before-stitch.test.lua >>> index d750b721..6e8f70c2 100644 >>> --- a/test/tarantool-tests/lj-720-errors-before-stitch.test.lua >>> +++ b/test/tarantool-tests/lj-720-errors-before-stitch.test.lua > > --------------0RXcbQAT0j67R06Bs5UKE0Rd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Sergey

thanks for the fixes and answers!

See my answers below.

On 13.06.2024 13:25, Sergey Kaplun wrote:
Hi, Sergey!
Thanks for the review!
Please consider my answers below.

On 06.06.24, Sergey Bronnikov wrote:
<snipped>
--- /dev/null
+++ b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua
@@ -0,0 +1,46 @@
+local tap = require('tap')
+
+-- Test file to demonstrate unbalanced Lua stack after instruction
+-- recording due to throwing an error at recording of a stitched
+-- function.
+-- See also:https://github.com/LuaJIT/LuaJIT/issues/1166.
+
+local test = tap.test('lj-1166-error-stitch-oom-snap-buff'):skipcond({
should a name in tap.test match to test file name?

now it is not.
My mistake during copipasting. Fixed.
Thanks!

      

        
+  ['Test requires JIT enabled'] = not jit.status(),
+  ['Disabled on *BSD due to #4819'] = jit.os == 'BSD',
+})
+
+test:plan(1)
+
+local mockalloc = require('mockalloc')
+
+local function create_chunk(n_slots)
I would add a comment like this:


--- a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua
+++ b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua
@@ -14,6 +14,18 @@ test:plan(1)

  local mockalloc = require('mockalloc')

+-- Generate a Lua chunk like below:
+-- local s1
+-- local s2
+-- ...
+-- local sN
+-- for i = 1, 2 do
+--   s1 = i + 1
+--   s2 = i + 2
+--   ...
+--   sN = i + N
+--   math.modf(1)
+-- end
  local function create_chunk(n_slots)
    local chunk = ''
    for i = 1, n_slots do
Added, see the iterative patch below.

Thanks!




+  local chunk = ''
<snipped>

+
+local mockalloc = require('mockalloc')
+
+local function create_chunk(n_conds)
the same as above: please add a comment with an example of generated Lua 
chunk
Added, see the iterative patch below.

Thanks!
diff --git a/test/tarantool-tests/lj-1166-error-stitch-table-bump.test.lua b/test/tarantool-tests/lj-1166-error-stitch-table-bump.test.lua
new file mode 100644
index 00000000..f2453bbe
--- /dev/null
+++ b/test/tarantool-tests/lj-1166-error-stitch-table-bump.test.lua
this test is not failed after reverting patch
Do you build luajit with -DLUAJIT_ENABLE_TABLE_BUMP=ON?

<snipped>

My bad. With enabled option tests failed:

The following tests FAILED:
        127 - test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua (SEGFAULT)
        128 - test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua (SEGFAULT)
        129 - test/tarantool-tests/lj-1166-error-stitch-table-bump.test.lua (SEGFAULT)
Errors while running CTest

diff --git a/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c b/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c
new file mode 100644
index 00000000..d6d3492e
--- /dev/null
+++ b/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c
@@ -0,0 +1,51 @@
<snipped>

+
+/* Function to be used instead of the default allocator. */
+static void *mock_allocf(void *ud, void *ptr, size_t osize, size_t nsize)
+{
+	assert(old_allocf != NULL);
+	/*
+	 * Check the specific reallocation related to the IR
+	 * buffer or the snapshot buffer.
+	 */
+	if (osize * 2 == nsize)
+		return NULL;
+	return old_allocf(ud, ptr, osize, nsize);
+}
+
+static int mock(lua_State *L)

It is actually not a test mock.

According to definition [1] test mock imitate a behavior of a real object.

Your memory allocator behaves as a real allocator, but in some cases it 
will return

a NULL instead of memory address. What if we rename "mock" to "allocator 
with fault injection"?
I renamed `mock_allocf` to `allocf_with_injection()` to avoid
confusing.

===================================================================
diff --git a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua
index cf3ab0f5..eb229a5c 100644
--- a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua
+++ b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua
@@ -5,7 +5,7 @@ local tap = require('tap')
 -- function.
 -- See also: https://github.com/LuaJIT/LuaJIT/issues/1166.
 
-local test = tap.test('lj-1166-error-stitch-oom-snap-buff'):skipcond({
+local test = tap.test('lj-1166-error-stitch-oom-ir-buff'):skipcond({
   ['Test requires JIT enabled'] = not jit.status(),
   ['Disabled on *BSD due to #4819'] = jit.os == 'BSD',
 })
@@ -22,6 +22,16 @@ jit.flush()
 
 test:plan(2)
 
+-- Generate the following Lua chunk:
+-- local s1
+-- ...
+-- local sN
+-- for i = 1, 2 do
+--   s1 = i + 1
+--   ...
+--   sN = i + N
+--   math.modf(1)
+-- end
 local function create_chunk(n_slots)
   local chunk = ''
   for i = 1, n_slots do
diff --git a/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua b/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua
index 8bbdd96b..8ae26386 100644
--- a/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua
+++ b/test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua
@@ -20,6 +20,13 @@ jit.flush()
 
 test:plan(2)
 
+-- Generate the following Lua chunk:
+-- for i = 1, 2 do
+--   if i < 1 then end
+--   ...
+--   if i < N then end
+--   math.modf(1)
+-- end
 local function create_chunk(n_conds)
   local chunk = ''
   chunk = chunk .. 'for i = 1, 2 do\n'
diff --git a/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c b/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c
index d6d3492e..19d32f8b 100644
--- a/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c
+++ b/test/tarantool-tests/lj-1166-error-stitch/mockalloc.c
@@ -8,7 +8,8 @@ static lua_Alloc old_allocf = NULL;
 static void *old_alloc_state = NULL;
 
 /* Function to be used instead of the default allocator. */
-static void *mock_allocf(void *ud, void *ptr, size_t osize, size_t nsize)
+static void *allocf_with_injection(void *ud, void *ptr, size_t osize,
+				   size_t nsize)
 {
 	assert(old_allocf != NULL);
 	/*
@@ -24,14 +25,14 @@ static int mock(lua_State *L)
 {
 	assert(old_allocf == NULL);
 	old_allocf = lua_getallocf(L, &old_alloc_state);
-	lua_setallocf(L, mock_allocf, old_alloc_state);
+	lua_setallocf(L, allocf_with_injection, old_alloc_state);
 	return 0;
 }
 
 static int unmock(lua_State *L)
 {
 	assert(old_allocf != NULL);
-	assert(old_allocf != mock_allocf);
+	assert(old_allocf != allocf_with_injection);
 	lua_setallocf(L, old_allocf, old_alloc_state);
 	old_allocf = NULL;
 	old_alloc_state = NULL;
===================================================================

Filename and other variables still use prefix "mock":

[0] ~/sources/MRG/tarantool/third_party/luajit$ grep -R mock test
test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua:local mockalloc = require('mockalloc')
test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua:mockalloc.mock()
test/tarantool-tests/lj-1166-error-stitch-oom-snap-buff.test.lua:mockalloc.unmock()
test/tarantool-tests/CMakeLists.txt:# Some tests use `LD_PRELOAD` to mock system calls (like
test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua:local mockalloc = require('mockalloc')
test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua:mockalloc.mock()
test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua:mockalloc.unmock()
test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:static int mock(lua_State *L)
test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:static int unmock(lua_State *L)
test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:static const struct luaL_Reg mockalloc[] = {
test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:  {"mock", mock},
test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:  {"unmock", unmock},
test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:LUA_API int luaopen_mockalloc(lua_State *L)
test/tarantool-tests/lj-1166-error-stitch/mockalloc.c:  luaL_register(L, "mockalloc", mockalloc);
test/tarantool-tests/lj-1166-error-stitch/CMakeLists.txt:BuildTestCLib(mockalloc mockalloc.c)

have you left it intentionally?


1. https://www.martinfowler.com/articles/mocksArentStubs.html

+{
<snipped>

diff --git a/test/tarantool-tests/lj-720-errors-before-stitch.test.lua b/test/tarantool-tests/lj-720-errors-before-stitch.test.lua
index d750b721..6e8f70c2 100644
--- a/test/tarantool-tests/lj-720-errors-before-stitch.test.lua
+++ b/test/tarantool-tests/lj-720-errors-before-stitch.test.lua
<snipped>

--------------0RXcbQAT0j67R06Bs5UKE0Rd--