Skip to content

Reset process state between MSBuild server requests - #14475

Merged
JanProvaznik merged 8 commits into
mainfrom
copilot/fix-process-state-leaks
Jul 27, 2026
Merged

JanProvaznik merged 8 commits into
mainfrom
copilot/fix-process-state-leaks

Conversation

Copilot AI commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Work item (Internal use):

Summary

Reusable server processes retained deferred logger messages and /lowPriority state across requests.

  • Clear per-request deferred messages during ResetBuildState().
  • Capture process priority before lowering it and restore it at the next request boundary.
  • Preserve reusable engine and project caches.

Customer Impact

Prevents duplicate/stale diagnostics, unbounded message accumulation, and normal builds running at inherited low priority.

Regression?

Yes. Mutable process state was not included in the server request reset boundary.

Testing

Added reused-server regressions covering deferred-message accumulation and Windows process-priority restoration.

Risk

Low. Changes are limited to per-request state reset; priority restoration remains best-effort where denied by the OS.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hello @copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo.

Copilot AI changed the title [WIP] Fix process state leaks between server requests Reset process state between MSBuild server requests Jul 21, 2026
Copilot AI requested a review from JanProvaznik July 21, 2026 11:53
@JanProvaznik
JanProvaznik marked this pull request as ready for review July 21, 2026 11:53
Copilot AI review requested due to automatic review settings July 21, 2026 11:53

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.

Pull request overview

This PR fixes MSBuild Server request isolation by resetting mutable process state between requests so that a long-lived server node doesn’t leak diagnostics or OS process priority across builds.

Changes:

  • Clear per-request deferred logger messages during ResetBuildState() to prevent duplicated/stale diagnostics and message growth across server requests.
  • Capture the original process priority before applying -low and restore it at the next request boundary.
  • Add server-reuse regression tests covering deferred-message accumulation and Windows process-priority restoration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/MSBuild/XMake.cs Resets per-request deferred logger messages and restores process priority at request boundaries for MSBuild Server reuse.
src/MSBuild.UnitTests/MSBuildServer_Tests.cs Adds regression tests validating deferred messages don’t accumulate across server builds and -low priority does not leak.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 212b78a7-a261-41ac-8918-1eedd0fbaf94
Enable the Process property function for .NET Framework and assert that the server restores its inherited priority.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 212b78a7-a261-41ac-8918-1eedd0fbaf94
@JanProvaznik
JanProvaznik merged commit 867c136 into main Jul 27, 2026
11 checks passed
@JanProvaznik
JanProvaznik deleted the copilot/fix-process-state-leaks branch July 27, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

process state leaks between server requests

4 participants