Skip to content

Fix Windows diagnostic server ignoring a client that connects before ConnectNamedPipe - #138447

Open
MattParkerDev wants to merge 1 commit into
dotnet:mainfrom
MattParkerDev:fix-diag-ipc-bug
Open

MattParkerDev wants to merge 1 commit into
dotnet:mainfrom
MattParkerDev:fix-diag-ipc-bug

Conversation

@MattParkerDev

@MattParkerDev MattParkerDev commented Nov 28, 2026 •

Copy link
Copy Markdown

On Windows, a client can connect to the diagnostic server's named pipe between CreateNamedPipeA and the overlapped ConnectNamedPipe in ds_ipc_listen. ConnectNamedPipe then fails with ERROR_PIPE_CONNECTED, and because no overlapped operation was started, overlap.hEvent is never signaled. ds_ipc_listen treats this as success, but ds_ipc_poll waits on that event forever. The connected client's request is never read, and because the pipe instance stays connected, no other client can get through either.

This is easy to hit when resuming a process started with DOTNET_DefaultDiagnosticPortSuspend=1. DiagnosticsClient retries NamedPipeClientStream.Connect until the pipe exists, so a ResumeRuntime sent right after process start connects as soon as the pipe appears. When it lands in this window, ResumeRuntime never returns and the runtime stays paused at startup indefinitely.

Fix:

  • In the ERROR_PIPE_CONNECTED case, signal overlap.hEvent so poll sees the connection, and record it in a new is_client_connected flag.
  • In ds_ipc_accept, skip GetOverlappedResult when the flag is set, since there is no overlapped connect to complete.
  • Clear the flag wherever the listen state is reset.

ERROR_IO_PENDING no longer falls through into the ERROR_PIPE_CONNECTED case.

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 28, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Diagnostics-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant