Intermittent dotnet build hang: Thread pool exhaustion?
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 141
Description
### Issue Description
With one of our projects we are experiencing intermittent hangs of dotnet invocation of MSBuild. It is not clear why this happens but we've seen it with both test projects and regular builds that are (supposed to) deploy via msdeploy to a test environment.
No output is written to stdout, and the process hangs indefinitely until it is eventually terminated after our build server loses patience - after over an hour.
### Steps to Reproduce
I can share confidential memory dumps if desired. We have taken multiple measures to run into the issues mentioned in other issues:
- MSBUILDDISABLENODEREUSE
- MSBUILDENSURESTDOUTFORTASKPROCESSES
- Shut down build server after each build
- UseRazorBuildServer set to false
- UseSharedCompilation set to false
### Expected Behavior
The build finishes successfully or gives an error message.
### Actual Behavior
The build hangs at a point after it finishes executing tests and written the results to stdout, or otherwise finished executing the targets of the project files. We see one or multiple child processes with this command line:
```
"C:\Program Files\dotnet\dotnet.exe" "C:\Program Files\dotnet\sdk\6.0.101\MSBuild.dll" /nologo /nodemode:1 /nodeReuse:false /low:false
```

### Analysis
I took menory dumps of the parent and child process, and in all cases I find in the parent process the following after analysis in Visual Studio:

*AA0008: Thread pool is out of threads*

*Parallel stacks shows no user code*

*Child process dump analysis also shows: AA0005 Thread pool is out of threads due to blocked async method*

*Parallel stacks of the child process*
Automatic lock analysis of `dotnet dump analyze` doesn't give any results.
### Versions & Configurations
Running dotnet SDK `6.0.101`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.