aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/loop_spec.lua
diff options
context:
space:
mode:
authorphanium <91544758+phanen@users.noreply.github.com>2025-02-25 05:34:49 +0800
committerGitHub <noreply@github.com>2025-02-24 13:34:49 -0800
commit614c9322d50052c76fb3e6e1be7536a972ff0902 (patch)
tree5559e0086a7c7673cb10db7d2315806520383e0d /test/functional/lua/loop_spec.lua
parent56fabcadb6df46c70402e4f9cd1b851856fb57e9 (diff)
downloadrneovim-614c9322d50052c76fb3e6e1be7536a972ff0902.tar.gz
rneovim-614c9322d50052c76fb3e6e1be7536a972ff0902.tar.bz2
rneovim-614c9322d50052c76fb3e6e1be7536a972ff0902.zip
fix(lua): SIGSEGV in luv callback with error(nil) #32595
Problem: luv callback `vim.uv.new_timer():start(0, 0, function() error() end)` causes SIGSEGV, since `xstrdup` gets NULL from `lua_tostring`. Similar to: https://github.com/neovim/neovim/commit/a5b1b83a2693ffa7a5a0a22b3693d36ea60051be Solution: Check NULL before `xstrdup`.
Diffstat (limited to 'test/functional/lua/loop_spec.lua')
-rw-r--r--test/functional/lua/loop_spec.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/functional/lua/loop_spec.lua b/test/functional/lua/loop_spec.lua
index 52a8fec0bf..8df2900368 100644
--- a/test/functional/lua/loop_spec.lua
+++ b/test/functional/lua/loop_spec.lua
@@ -159,4 +159,39 @@ describe('vim.uv', function()
it("is equal to require('luv')", function()
eq(true, exec_lua("return vim.uv == require('luv')"))
end)
+
+ it('non-string error() #32595', function()
+ local screen = Screen.new(50, 10)
+ exec_lua(function()
+ local timer = assert(vim.uv.new_timer())
+ timer:start(0, 0, function()
+ timer:close()
+ error(nil)
+ end)
+ end)
+ local s = [[
+ |
+ {1:~ }|*5
+ {3: }|
+ {9:Error executing callback:} |
+ {9:[NULL]} |
+ {6:Press ENTER or type command to continue}^ |
+ ]]
+ screen:expect(s)
+ feed('<cr>')
+ n.assert_alive()
+ screen:expect([[
+ ^ |
+ {1:~ }|*8
+ |
+ ]])
+ exec_lua(function()
+ vim.uv.fs_stat('non-existent-file', function()
+ error(nil)
+ end)
+ end)
+ screen:expect(s)
+ feed('<cr>')
+ n.assert_alive()
+ end)
end)