From edd89f66a4633581b6a4d05d63dbaef0a8bb9fc8 Mon Sep 17 00:00:00 2001 From: Thomas Kosiewski Date: Thu, 12 Nov 2026 05:46:37 +0000 Subject: [PATCH] docs(diff): name the Neovim versions that LuaJIT #1066 affects The comments on the workaround for LuaJIT issue #1066 said that Neovim 0.8.0 bundles the bug. Neovim 0.9.5 bundles LuaJIT 2.1.1692716794 (commit 03c31124), which is 70 commits older than the fix e86990f7f of 21 September 2023. On 0.9.5 the minimal repro aborts in 10 of 10 runs, and the spec without the call fails in 29 of 32 runs. Neovim 0.10.0 bundles 75e92777, 87 commits after the fix (by GitHub compare, not run). Say "older than September 2023 (bundled by Neovim 0.8 and 0.9)", so nobody deletes the call when the minimum version moves to 0.9. Comments only. --- .agents/skills/verify-diff-lifecycle/covered.lock | 4 ++-- lua/claudecode/diff.lua | 8 ++++---- tests/integration/diff_failed_setup_guards_spec.lua | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.agents/skills/verify-diff-lifecycle/covered.lock b/.agents/skills/verify-diff-lifecycle/covered.lock index 3bf18cae4..f8acdf388 100644 --- a/.agents/skills/verify-diff-lifecycle/covered.lock +++ b/.agents/skills/verify-diff-lifecycle/covered.lock @@ -3,11 +3,11 @@ file lua/claudecode/config.lua 787fa0432d1d77d7 == lua/claudecode/cwd.lua file lua/claudecode/cwd.lua 35b7af3572d13018 == lua/claudecode/diff.lua -file lua/claudecode/diff.lua ab11e592a3f2c13d +file lua/claudecode/diff.lua eea6b4bcdd655787 block resolve_saved 46d5f3f732711fe1 block resolve_rejected c7a620816abff9a1 block open_blocking 92067df7f9d4d4d9 -block setup_blocking 257189386f7b6147 +block setup_blocking b96c84e0961817fc block close_by_name cc40c0d2ffdf7946 block close_pending 31bc827d1065da70 block close_for_client 330cc91666bc7884 diff --git a/lua/claudecode/diff.lua b/lua/claudecode/diff.lua index 19d9b4518..ecdaf2597 100644 --- a/lua/claudecode/diff.lua +++ b/lua/claudecode/diff.lua @@ -1867,10 +1867,10 @@ function M._setup_blocking_diff(params, resolution_callback) end end - -- A raising handler of the user (autocmd callback) makes the cleanup above fail inside Neovim API calls. Neovim - -- 0.8.0 bundles a LuaJIT that then keeps pointing at the main Lua thread, while this code runs in the coroutine - -- of tools.handle_invoke. The next JIT trace exit corrupts the stack of the main thread and Neovim aborts or - -- crashes, exit 134 or 139 (LuaJIT issue #1066, fixed in September 2023). An API call that returns normally points + -- A raising handler of the user (autocmd callback) makes the cleanup above fail inside Neovim API calls. A LuaJIT + -- older than September 2023 (bundled by Neovim 0.8 and 0.9) then keeps pointing at the main Lua thread, while this + -- code runs in the coroutine of tools.handle_invoke. The next JIT trace exit corrupts the stack of the main thread + -- and Neovim aborts or crashes, exit 134 or 139 (LuaJIT issue #1066). An API call that returns normally points -- LuaJIT at the running coroutine again. Make one before the error leaves the coroutine. vim.api.nvim_get_current_tabpage() diff --git a/tests/integration/diff_failed_setup_guards_spec.lua b/tests/integration/diff_failed_setup_guards_spec.lua index 58d4762e8..eedc21713 100644 --- a/tests/integration/diff_failed_setup_guards_spec.lua +++ b/tests/integration/diff_failed_setup_guards_spec.lua @@ -143,12 +143,12 @@ describe("openDiff when the setup fails in a new tab", function() closes_the_new_tab_and_goes_back(a_BufLeave_handler_raises_during_the_cleanup) end) - -- Neovim 0.8.0 bundles a LuaJIT with a bug (LuaJIT issue #1066, fixed in September 2023). When a Neovim API call - -- raises inside a coroutine because a handler it ran raised, LuaJIT keeps pointing at the main Lua thread, and the - -- next JIT trace exit corrupts the stack of that thread. Neovim then aborts (exit 134, "bad stack slot") or crashes - -- (exit 139), and plenary prints no summary. openDiff runs in a coroutine (tools.handle_invoke). The three cases - -- above hit the bug in a few of 100 runs. A JIT that compiles at once makes the passes below hit it in most runs, - -- so this case fails on Neovim 0.8.0 when diff.lua leaves the bug in place. + -- A LuaJIT older than September 2023 (bundled by Neovim 0.8 and 0.9) has a bug (LuaJIT issue #1066). When a Neovim + -- API call raises inside a coroutine because a handler it ran raised, LuaJIT keeps pointing at the main Lua thread, + -- and the next JIT trace exit corrupts the stack of that thread. Neovim then aborts (exit 134, "bad stack slot") or + -- crashes (exit 139), and plenary prints no summary. openDiff runs in a coroutine (tools.handle_invoke). On Neovim + -- 0.8.0 the three cases above hit the bug in a few of 100 runs. A JIT that compiles at once makes the passes below + -- hit it in most runs, so this case fails on Neovim 0.8 and 0.9 when diff.lua leaves the bug in place. it("keeps Neovim running when handlers raise on repeated failed setups under an eager JIT", function() if jit then jit.opt.start("hotloop=1", "hotexit=1", "tryside=1")