<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p>Hi, Sergey!</p>
<p>thanks for the patch! LGTM with a minor comment below.</p>
<p>Sergey</p>
<div class="moz-cite-prefix">On 3/28/26 18:31, Sergey Kaplun wrote:<br>
</div>
<p><br>
</p>
<p><snipped></p>
<blockquote type="cite"
cite="mid:7c96f2917ce5525a7799a1f327e0981d9a59f84f.1774711616.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
diff --git a/test/tarantool-tests/lj-1403-vmevent-crash-on-stkov.test.lua b/test/tarantool-tests/lj-1403-vmevent-crash-on-stkov.test.lua
new file mode 100644
index 00000000..ad275e17
--- /dev/null
+++ b/test/tarantool-tests/lj-1403-vmevent-crash-on-stkov.test.lua
@@ -0,0 +1,47 @@
+local tap = require('tap')
+
+-- The test file to demonstrate LuaJIT crash during stack overflow
+-- in the VM event handle.
+-- See also, <a class="moz-txt-link-freetext" href="https://github.com/LuaJIT/LuaJIT/issues/1403">https://github.com/LuaJIT/LuaJIT/issues/1403</a>.
+
+local test = tap.test('lj-1403-vmevent-crash-on-stkov'):skipcond({
+ ['Test requires JIT enabled'] = not jit.status(),
+})
+
+test:plan(1)
+
+local jit_dump = require('jit.dump')
+
+-- XXX: Some specific stack usage without a stack top check by the
+-- Lua function header.
+local t = setmetatable({}, {__newindex = pcall, __call = type})</pre>
</blockquote>
<p>reproduced without __call metamethod, please add a comment with
explanation</p>
<p>why it is needed</p>
<blockquote type="cite"
cite="mid:7c96f2917ce5525a7799a1f327e0981d9a59f84f.1774711616.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
+-- luacheck: no unused
+local function prober(...)
+ -- Invokes `pcall(t, t, t)`.
+ t[t] = t
+end
+
+jit.opt.start('hotloop=1')
+-- Need the invocation of the VM event.
+jit_dump.start('i', '/dev/null')
+
+-- The code below causes the stack overflow in the VM event
+-- handler. The unwinding of the error breaks the JIT semantics
+-- and leads to a crash.
+local function looper()
+ local r = pcall(prober)
+ if not r then
+ local n = 1
+ while n < 3 do
+ prober(1, 2)
+ n = n + 1
+ end
+ end
+ looper()
+end
+
+pcall(coroutine.wrap(looper))
+
+test:ok(true, 'no crash')
+
+test:done(true)
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>