[release/7.0] Update ds-ipc-pal-namedpipe to fix shutdown race #89620
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partial fix for #89621
Description
Works around a regression introduced in 7.0.9 around reading/writing to the IPC while VM shutdown is happening. The diagnostic server thread might race VM shutdown, and end up using an IPC handle that has been closed as part of a GetOverlappedResult call, that in turn will end up closing the handle.
The shutdown cleanup was added as a measure to ensure mono on Windows embedding scenarios would work after the EventPipe IPC got torn down.
Customer Impact
This can lead to hard to diagnose bugs on embedding scenarios where handle reuse is possible and the race will cause reused handles to be closed or odd reading behavior that's hard to diagnose. Currently EventPipe doesn't have any coordination mechanism during shutdown to make sure diagnostic server thread stops during shutdown, so it can't close any of the resources since they might still be used and their error paths lead to unexpected results.
Regression
Fixes regression introduced during last servicing.
Risk
Regresses scenario of embedding mono on Windows.