Skip to content

Add logging for a hung BuildHost during shutdown - #85908

Open
jasonmalinowski wants to merge 2 commits into
dotnet:mainfrom
jasonmalinowski:add-logging-for-hung-buildhost
Open

jasonmalinowski wants to merge 2 commits into
dotnet:mainfrom
jasonmalinowski:add-logging-for-hung-buildhost

Conversation

@jasonmalinowski

@jasonmalinowski jasonmalinowski commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

This increases the timeout to wait for a hung BuildHost, and if we do see one, it'll take a crash dump of the process first.

Microsoft Reviewers: Open in CodeFlow

@jasonmalinowski jasonmalinowski self-assigned this Oct 3, 2026
Copilot AI balanced review requested due to automatic review settings October 3, 2026 01:19
@jasonmalinowski
jasonmalinowski requested review from a team as code owners October 3, 2026 01:19
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@jasonmalinowski jasonmalinowski changed the title Add logging for hung buildhost Add logging for a hung BuildHost during shutdown Oct 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Shutdown can still leave processes alive or undiagnosed, and the new behavior lacks regression coverage.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Adds Helix diagnostics for BuildHost processes that hang during MSBuildWorkspace shutdown.

Changes:

  • Extends the shutdown grace period from 0.5 to 5 seconds.
  • Captures dumps before terminating hung BuildHosts.
  • Moves dump collection into shared test utilities.

Assessment: The approach is reasonable, but callback failures can prevent termination, the TryApplyChanges BuildHost is not instrumented, and regression coverage is missing.

File Description
src/​Workspaces/​MSBuild/​Test/​MSBuildWorkspaceTestBase.cs Configures Helix dump collection.
src/​Workspaces/​MSBuild/​Core/​MSBuild/​MSBuildWorkspace.cs Exposes the test hook.
src/​Workspaces/​MSBuild/​Core/​MSBuild/​MSBuildProjectLoader.cs Forwards the shutdown hook.
src/​Workspaces/​MSBuild/​Core/​MSBuild/​BuildHostProcessManager.cs Extends timeout and invokes diagnostics before killing.
src/​Tools/​RunTests/​RunTests.csproj Removes the direct diagnostics dependency.
src/​Tools/​RunTests/​Program.cs Uses the shared dump collector.
src/​Tools/​RunTests/​DumpCollector.cs Removes the local implementation.
src/​Compilers/​Test/​Core/​Microsoft.CodeAnalysis.Test.Utilities.csproj Adds the diagnostics-client dependency.
src/​Compilers/​Test/​Core/​DumpCollector.cs Introduces the shared dump utility.

Comment thread src/Workspaces/MSBuild/Core/MSBuild/MSBuildWorkspace.cs
Comment on lines +561 to +567
_process.WaitForExit(milliseconds: 5_000);

if (!_process.HasExited)
{
LogProcessFailure();

_beforeKillHungBuildHostProcess?.Invoke(_process);
This allows it to be used more broadly in other tests.
It's unclear to us if we're getting some build hosts sticking around
when we shouldn't; this adds extra logging if a process stays around
well after it shold have gone away.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 01:24
@jasonmalinowski
jasonmalinowski force-pushed the add-logging-for-hung-buildhost branch from a5fd468 to 3e70a65 Compare October 3, 2026 01:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

A hung shutdown RPC bypasses the timeout, dump, and forced-termination path entirely.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity · 1 Low severity

Open (3)

Comment thread src/Workspaces/MSBuild/Core/MSBuild/BuildHostProcessManager.cs

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants