diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-04-25 20:07:22 +0800 |
|---|---|---|
| committer | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2026-04-25 12:38:20 +0000 |
| commit | f0baa1804384b96a03d6c0ed637f7b543f03ff5c (patch) | |
| tree | e3c12e627e6a361f4ac266544240062759e4b92d /test | |
| parent | e5114d03b589511e5ce8c47d8e9de62b45a583e4 (diff) | |
fix(channel): stack-buffer-overflow with exit during connection (#39387)release-0.12
Problem: When Nvim exits while connecting to a socket it leads to
stack-buffer-overflow.
Solution: Associate the handle with the Stream and use the Stream's
internal_close_cb to update the "closed" status.
(cherry picked from commit 4ed2e66d2ec20c2bf0325283b0e785ca3abb15c0)
Diffstat (limited to 'test')
| -rw-r--r-- | test/functional/core/channels_spec.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua index 3329e1c783..6470909fd9 100644 --- a/test/functional/core/channels_spec.lua +++ b/test/functional/core/channels_spec.lua @@ -505,6 +505,27 @@ describe('channels', function() ) end) end) + + it('no stack-buffer-overflow with Nvim exit during connection #39387', function() + local nvim0 = n.get_session() + -- Need a valid pipe so that connecting to it doesn't fail immediately. + local server = fn.serverstart() + finally(function() + nvim0:close() + end) + + n.set_session(n.new_session(true)) + exec_lua(function() + vim.defer_fn(function() + vim.uv.sleep(50) -- Block the uv event loop. + vim.fn.sockconnect('pipe', server) + end, 10) + end) + vim.uv.sleep(20) + -- The server uv event loop is currently blocked, so the channel close will + -- be processed when sockconnect() polls. + n.check_close() + end) end) describe('loopback', function() |
