diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-04-25 20:07:22 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-25 20:07:22 +0800 |
| commit | 4ed2e66d2ec20c2bf0325283b0e785ca3abb15c0 (patch) | |
| tree | 0cee6a4f0935f91802530092d24b7afa2000413a /test | |
| parent | fb795cee3e1603de5fe632a4aad11650a6da88d4 (diff) | |
fix(channel): stack-buffer-overflow with exit during connection (#39387)
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.
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() |
