Fix DrainPacketQueue threads leaking - #14135
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a potential leak of the dedicated DrainPacketQueue thread in NodeProviderOutOfProcBase.NodeContext by ensuring the “exit packet” termination condition is evaluated even when the write path throws (e.g., broken/disposed pipe), which is particularly important for long-lived hosts like Visual Studio.
Changes:
- Moves the
NodeBuildCompleteexit/return logic out of the packet writetryblock so it runs even when write exceptions are swallowed. - Adds a detailed comment explaining the leak scenario and why the check must run after the exception handling.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
rainersigwald
approved these changes
Jun 22, 2026
AlesProkop
enabled auto-merge (squash)
June 23, 2026 12:34
This was referenced Jun 24, 2026
This was referenced Jun 24, 2026
ViktorHofer
pushed a commit
that referenced
this pull request
Jun 29, 2026
Quarantines 5 flaky tests detected by the automated flaky-test detector across `main` rolling builds and approved PRs. All failures are confined to Windows legs (`FullOnWindows`, `FullOnWindows Release`, `CoreOnWindows`) with `net472` TFM, so each is scoped with `TestPlatforms.Windows`. --- ## 1. `CoordinatorServer_Tests.ConcurrentClients_AllReceiveGrants` **Flaky-test key** (automated de-duplication — do not edit): ```text flaky-test-id: Microsoft.Build.Coordinator.UnitTests.CoordinatorServer_Tests.ConcurrentClients_AllReceiveGrants ``` **Action:** Quarantine (6a) Tracked by #14193 - **Distinct sources:** 7 (3 PRs + 4 rolling `main` builds) - **PRs:** #14104, #14130, #14135 - **Rolling builds:** [1472231](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1472231), [1472331](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1472331), [1477803](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1477803), [1478840](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1478840) - **Legs:** CoreOnWindows, FullOnWindows, FullOnWindows Release | **TFM:** net472 - **First seen:** 2026-06-19 | **Last seen:** 2026-06-24 - **Sample error:** `System.IO.IOException: The semaphore timeout period has expired.` --- ## 2. `MSBuildServer_Tests.CanShutdownServerProcess` **Flaky-test key** (automated de-duplication — do not edit): ```text flaky-test-id: Microsoft.Build.Engine.UnitTests.MSBuildServer_Tests.CanShutdownServerProcess ``` **Action:** Quarantine (6a) Tracked by #14195 - **Distinct sources:** 3 (rolling `main` builds only) - **Rolling builds:** [1464065](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1464065), [1475010](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1475010), [1481906](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1481906) - **Legs:** FullOnWindows, FullOnWindows Release | **TFM:** net472 - **First seen:** 2026-06-15 | **Last seen:** 2026-06-25 - **Error hashes:** 4 distinct signatures - **Sample error:** `System.InvalidOperationException: Couldn't get process information from performance counter.` --- ## 3. `XMakeAppTests.GetCommandLine` **Flaky-test key** (automated de-duplication — do not edit): ```text flaky-test-id: Microsoft.Build.UnitTests.XMakeAppTests.GetCommandLine ``` **Action:** Quarantine (6a) Tracked by #14194 - **Distinct sources:** 3 (rolling `main` builds only) - **Rolling builds:** [1464065](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1464065), [1475010](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1475010), [1481906](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1481906) - **Legs:** FullOnWindows, FullOnWindows Release | **TFM:** net472 - **First seen:** 2026-06-15 | **Last seen:** 2026-06-25 - **Error hashes:** 4 distinct signatures - **Sample error:** command-line path assertion mismatch on Windows (`ShouldContain` failure for `MSBuild.exe /v:diag` path) --- ## 4. `XMakeAppTests.GetCommandLineQuotedExe` **Flaky-test key** (automated de-duplication — do not edit): ```text flaky-test-id: Microsoft.Build.UnitTests.XMakeAppTests.GetCommandLineQuotedExe ``` **Action:** Quarantine (6a) Tracked by #14192 - **Distinct sources:** 3 (rolling `main` builds only) - **Rolling builds:** [1464065](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1464065), [1475010](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1475010), [1481906](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1481906) - **Legs:** FullOnWindows, FullOnWindows Release | **TFM:** net472 - **First seen:** 2026-06-15 | **Last seen:** 2026-06-25 - **Error hashes:** 4 distinct signatures - **Sample error:** command-line path assertion mismatch on Windows (`ShouldContain` failure for `MSBuild.exe /v:diag` path) --- ## 5. `XMakeAppTests.GetCommandLineQuotedExeOnPath` **Flaky-test key** (automated de-duplication — do not edit): ```text flaky-test-id: Microsoft.Build.UnitTests.XMakeAppTests.GetCommandLineQuotedExeOnPath ``` **Action:** Quarantine (6a) Tracked by #14196 - **Distinct sources:** 3 (rolling `main` builds only) - **Rolling builds:** [1464065](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1464065), [1475010](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1475010), [1481906](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1481906) - **Legs:** FullOnWindows, FullOnWindows Release | **TFM:** net472 - **First seen:** 2026-06-15 | **Last seen:** 2026-06-25 - **Error hashes:** 4 distinct signatures - **Sample error:** command-line path assertion mismatch on Windows (`ShouldContain` failure for `MSBuild.exe /v:diag` path) > Generated by [Flaky Test Triage](https://github.com/dotnet/msbuild/actions/runs/28321861359) · 610.5 AIC · ⊞ 34.9K · [◷](https://github.com/search?q=repo%3Adotnet%2Fmsbuild+%22gh-aw-workflow-id%3A+flaky-test-detector.agent%22&type=pullrequests) <!-- gh-aw-agentic-workflow: Flaky Test Triage, engine: copilot, version: 1.0.60, model: claude-sonnet-4.6, id: 28321861359, workflow_id: flaky-test-detector.agent, run: https://github.com/dotnet/msbuild/actions/runs/28321861359 --> <!-- gh-aw-workflow-id: flaky-test-detector.agent --> <!-- gh-aw-workflow-call-id: dotnet/msbuild/flaky-test-detector.agent --> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #
Context
DrainPacketQueue()has a dedicated thread for processing, and for long-lived hosts, these threads can be left alive due to an error that is swallowed.Changes Made
We can check for the exit condition outside of the
tryblock so that exceptions don't skip the check.Testing
Notes