Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where the IPC server can fully consume a CPU core and prevent incoming connections #102413

Merged
merged 2 commits into from
May 22, 2024

Conversation

davmason
Copy link
Member

If the call to CreateNamedPipe fails here:

ipc->pipe = CreateNamedPipeA (
ipc->pipe_name, // pipe name
creationFlags,
PIPE_TYPE_BYTE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS, // message type pipe, message-read and blocking mode
PIPE_UNLIMITED_INSTANCES, // max. instances
out_buffer_size, // output buffer size
in_buffer_size, // input buffer size
0, // default client time-out
NULL); // default security attribute
DS_EXIT_BLOCKING_PAL_SECTION;
if (ipc->pipe == INVALID_HANDLE_VALUE) {
if (callback)
callback ("Failed to create an instance of a named pipe.", GetLastError());
ep_raise_error ();
}

We will end up with an invalid handle for the pipe and the overlapped IO event. There currently is no code that tries to reset the connection and we will repeatedly try to poll an invalid handle, leading to one core being pegged as the wait fails due to an invalid handle and we keep waiting.

This PR makes it so we will call ds_ipc_listen when we run in to an error, which will reconnect to the named pipe. It also adds a delay when we detect an error, so if there are undetected cases that cause the same issue we will at least not consume the whole core we are running on.

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davmason davmason merged commit 4a99b64 into dotnet:main May 22, 2024
129 checks passed
steveharter pushed a commit to steveharter/runtime that referenced this pull request May 28, 2024
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull request May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants