Skip to content

win: fix crash when closing a pipe after a failed bind - #5224

Merged
saghul merged 1 commit into
libuv:v1.xfrom
yury-s:fix-pipe-pending-instances-crash
Aug 6, 2026
Merged

saghul merged 1 commit into
libuv:v1.xfrom
yury-s:fix-pipe-pending-instances-crash

Conversation

@yury-s

@yury-s yury-s commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

uv_pipe_pending_instances() sets the UV_HANDLE_PIPESERVER flag before the pipe is bound. When the subsequent bind fails (e.g. with UV_EADDRINUSE after losing a bind race on a well-known pipe name), uv_pipe_bind2() frees accept_reqs and resets it to NULL, but the flag stays set. Closing the handle then dereferences the NULL accept_reqs array in uv__pipe_close() — release builds crash with an access violation, debug builds trip the assert in uv__pipe_endgame().

This PR tolerates accept_reqs == NULL at both cleanup sites and adds a regression test (pipe_bind_error_addrinuse_pending_instances), which crashes with 0xC0000005 without the fix and passes with it.

Refs: nodejs/node#65057 (crash is reachable from Node.js via NODE_PENDING_PIPE_INSTANCES; reproduces on Node 22/24/26)

uv_pipe_pending_instances() sets the UV_HANDLE_PIPESERVER flag before the
pipe is bound. When the subsequent bind fails, e.g. with UV_EADDRINUSE
after losing a bind race on a well-known pipe name, uv_pipe_bind2() frees
accept_reqs and resets it to NULL, but the flag stays set. Closing the
handle then dereferences the NULL accept_reqs array in uv__pipe_close()
(release builds crash with an access violation; debug builds trip the
assert in uv__pipe_endgame()).

Tolerate accept_reqs == NULL at both cleanup sites.
@saghul
saghul merged commit a6d06ba into libuv:v1.x Aug 6, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants