-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Update IpcStreamFactory state machine to handle being started on a thread that ends #43711
Update IpcStreamFactory state machine to handle being started on a thread that ends #43711
Conversation
Tagging subscribers to this area: @tommcdon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I don't completely understand the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo few things 👍
/backport to release/5.0 |
Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/346557926 |
Fixes #39176
The first call to
IpcStream::DiagnosticsIpc::Listen
happens on the thread whereEEStartupHelper
executes. On Windows, if that thread ends, e.g., in a custom hosting scenario, it causes all Overlapped IO that started on that thread to be cancelled. This specifically includes the asynchronous call toConnectNamedPipe
inIpcStreamFactory
state machine. This causesGetNextAvailableStream
to go into an error state that would continually check the status of the aborted IO without attempting to reset itself. It always seeERROR_OPERATION_ABORTED
and doesn't self-correct. This patch accounts for mid-state change IO cancellations by automatically resetting the Listen port on the error.I reproduced the behavior from #39176 locally (12% CPU being consumed by the error state) and confirmed that this change fixed the issue (CPU is reported as 0% in the repro).
This patch also updates the write/read error code to only call
GetOverlappedResults
on infinite timeouts if the error fromReadFile
/WriteFile
wasERROR_IO_PENDING
.CC @tommcdon @lateralusX