diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2024-06-20 14:48:06 +0200 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2024-11-14 13:23:11 +0100 |
commit | de48fbbd5f8800bd7f1909a6fb41e53e871cf74c (patch) | |
tree | b394143235cc15259d6bf8b08729da73d5633ba4 /test/functional/vimscript/eval_spec.lua | |
parent | 7d771c3eeef5b4dca9ebc5ed6f7ca03f2b26b6bc (diff) | |
download | rneovim-de48fbbd5f8800bd7f1909a6fb41e53e871cf74c.tar.gz rneovim-de48fbbd5f8800bd7f1909a6fb41e53e871cf74c.tar.bz2 rneovim-de48fbbd5f8800bd7f1909a6fb41e53e871cf74c.zip |
fix(messages)!: vim.ui_attach message callbacks are unsafe
Problem: Lua callbacks for "msg_show" events with vim.ui_attach() are
executed when it is not safe.
Solution: Disallow non-fast API calls for "msg_show" event callbacks.
Automatically detach callback after excessive errors.
Make sure fast APIs do not modify Nvim state.
Diffstat (limited to 'test/functional/vimscript/eval_spec.lua')
-rw-r--r-- | test/functional/vimscript/eval_spec.lua | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index de1a3d7c73..2a4835f7e1 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -25,8 +25,6 @@ local command = n.command local write_file = t.write_file local api = n.api local sleep = vim.uv.sleep -local matches = t.matches -local pcall_err = t.pcall_err local assert_alive = n.assert_alive local poke_eventloop = n.poke_eventloop local feed = n.feed @@ -227,72 +225,6 @@ describe('listing functions using :function', function() exec_capture(('function <lambda>%s'):format(num)) ) end) - - it('does not crash if another function is deleted while listing', function() - local _ = Screen.new(80, 24) - matches( - 'Vim%(function%):E454: Function list was modified$', - pcall_err( - exec_lua, - [=[ - vim.cmd([[ - func Func1() - endfunc - func Func2() - endfunc - func Func3() - endfunc - ]]) - - local ns = vim.api.nvim_create_namespace('test') - - vim.ui_attach(ns, { ext_messages = true }, function(event, _, content) - if event == 'msg_show' and content[1][2] == 'function Func1()' then - vim.cmd('delfunc Func3') - end - end) - - vim.cmd('function') - - vim.ui_detach(ns) - ]=] - ) - ) - assert_alive() - end) - - it('does not crash if the same function is deleted while listing', function() - local _ = Screen.new(80, 24) - matches( - 'Vim%(function%):E454: Function list was modified$', - pcall_err( - exec_lua, - [=[ - vim.cmd([[ - func Func1() - endfunc - func Func2() - endfunc - func Func3() - endfunc - ]]) - - local ns = vim.api.nvim_create_namespace('test') - - vim.ui_attach(ns, { ext_messages = true }, function(event, _, content) - if event == 'msg_show' and content[1][2] == 'function Func1()' then - vim.cmd('delfunc Func2') - end - end) - - vim.cmd('function') - - vim.ui_detach(ns) - ]=] - ) - ) - assert_alive() - end) end) it('no double-free in garbage collection #16287', function() |