[Tarantool-patches] [PATCH luajit 2/2] Fix VM event error handling for finalizers.

Sergey Kaplun skaplun at tarantool.org
Mon Mar 30 12:44:58 MSK 2026


Hi, Sergey!
Thanks for the review!
Fixed the comments and force-pushed the branch.

On 30.03.26, Sergey Bronnikov wrote:
> Hi, Sergey!
> 
> thanks for the patch! LGTM with a couple of comments below
> 
> Sergey
> 
> On 3/28/26 18:31, Sergey Kaplun wrote:

<snipped>

> > diff --git a/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua b/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
> > new file mode 100644
> > index 00000000..def8b79c
> > --- /dev/null
> > +++ b/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
> > @@ -0,0 +1,27 @@
> > +local tap = require('tap')
> > +local test = tap.test('lj-1445-errfin-errmsg')
> > +
> 
> Usually you add a comment with test description and a link to the issue.
> 
> But this time a comment is absent. Should we add it?

Added, thanks!

===================================================================
diff --git a/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua b/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
index 7170065f..a52f6a06 100644
--- a/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
+++ b/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
@@ -1,4 +1,9 @@
 local tap = require('tap')
+
+-- The test file to demostrate LuaJIT's incorrect invocation of
+-- the VM event handler for the 'errfin' VM event.
+-- See also: https://github.com/LuaJIT/LuaJIT/issues/1445.
+
 local test = tap.test('lj-1445-errfin-errmsg')
 
 test:plan(2)
===================================================================

> 
> > +test:plan(2)
> > +
> > +local EXPECTED_ERR = 'expected err'
> 
> s/err/error/

Fixed:
===================================================================
diff --git a/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua b/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
index def8b79c..205cd2d0 100644
--- a/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
+++ b/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
@@ -3,7 +3,7 @@ local test = tap.test('lj-1445-errfin-errmsg')
 
 test:plan(2)
 
-local EXPECTED_ERR = 'expected err'
+local EXPECTED_ERR = 'expected error'
 local function bad_fin()
   error(EXPECTED_ERR)
 end
===================================================================

> 
> feel free to ignore
> 
> > +local function bad_fin()
> > +  error(EXPECTED_ERR)
> > +end
> > +local EXPECTED_LOCATION = debug.getinfo(bad_fin).linedefined + 1
> > +
> > +local match_err = false
> > +local match_line = false
> > +local function errfin_handler(errmsg)
> > +  match_err =errmsg:match(EXPECTED_ERR)
> > +  match_line =errmsg:match(EXPECTED_LOCATION)
> > +end
> > +
> > +jit.attach(errfin_handler, 'errfin')
> > +
> > +debug.getmetatable(newproxy(true)).__gc = bad_fin
> 
> I would define userdata previously for clarity:
> 
> local ud = newproxy(true)
> 
> and then use it in getmetatable().
> 
> feel free to ignore
> 

Don't want to use `ud = nil`. Added the comment.

===================================================================
diff --git a/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua b/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
index def8b79c..205cd2d0 100644
--- a/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
+++ b/test/tarantool-tests/lj-1445-errfin-errmsg.test.lua
@@ -18,6 +18,7 @@ end
 
 jit.attach(errfin_handler, 'errfin')
 
+-- Create the userdata with the finalizer and collect it.
 debug.getmetatable(newproxy(true)).__gc = bad_fin
 collectgarbage()
===================================================================

> 
> > +collectgarbage()
> > +
> > +test:ok(match_err, 'correct error message in errfin handler')
> > +test:ok(match_line, 'correct source line in errfin handler')
> > +
> > +test:done(true)

-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list