dotnet / dotnet/aspnetcore

Rewrite stdout/err redirection logic in ANCM

Open
#49,959 0 comments 0 reactions 0 assignees View on GitHub
area-networking feature-iis
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

The StandardStreamRedirection logic in ANCM uses `CancelSynchronousIo` to kick the redirection thread out of its blocking `ReadFile` call and waits a hardcoded 2 seconds to allow the thread to exit before it calls `TerminateThread` on the thread. This works reasonably well in the vast majority of cases (most of the time, the 2 seconds is enough), but occasionally, we have to resort to the `TerminateThread` and in a small number of _those_ cases, the thread might be doing something dangerous like holding the OS loader lock.

This is how we end up with issues like https://github.com/dotnet/aspnetcore/issues/45066.

#49942 improved upon this situation by making the timeout configurable (so the thread can have more than 2 seconds to exit), but it would be cleaner to eliminate `TerminateThread` usage here entirely.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.