Repository navigation
Prevent storing incomplete _remoteInvokeHandle.Process on error - #137025
Merged
mrek-msft merged 5 commits intoNov 18, 2026
Merged
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-extensions-hosting |
Member
|
Doesn't this just replace one failure with another? If accessing Or is the goal of this PR to make future test failures caused by this race easier to diagnose, but not to prevent them? |
Member
Author
|
@svick Considering catch of ArgumentException intention, I added same for InvalidOperationException. I also reworked it to call Dispose if we are unable to proceed with obtained Process. |
This was referenced Nov 19, 2026
lewing
added a commit
that referenced
this pull request
Nov 19, 2026
…137929) Fixes Issue #136992 on release/11.0. <!-- Issue Number --> main PR #137025 <!-- Link to PR if any that fixed this in the main branch. --> # Description <!-- Give a brief summary of the issue and how the pull request is fixing it. --> Whole, unmodified backport of 9ae326e. Changes only `src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/WindowsServiceTester.cs`. The test helper now obtains the service process's SafeHandle before assigning the Process to RemoteInvokeHandle. If the process exits before handle acquisition, the helper disposes the temporary Process and returns without retaining an incomplete Process that can make cleanup throw. # Customer Impact <!-- What is the impact to customers of not taking this fix? --> No product behavior changes. Without this test-only fix, Windows service tests can fail intermittently during cleanup, adding CI noise to release/11.0. # Regression <!-- Is this fixing a problem that was introduced in the most recent release, ie., fixing a regression? --> This fixes an existing test-helper race present on release/11.0; it is not a customer-facing product regression. # Testing <!-- What kind of testing has been done with the fix. --> - `git diff --check` passed. - `git diff -- src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/WindowsServiceTester.cs | git patch-id --stable` matched the source commit's patch ID: `3c8ec18b17b577a70a57170a026a92060eb1e27a`. - Installed the .NET 11 daily SDK with `dotnet-install --channel 11.0 --quality daily` (SDK `11.0.200-preview.26568.113`, macOS arm64). - `.dotnet/dotnet build src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/Microsoft.Extensions.Hosting.WindowsServices.Tests.csproj -p:TargetOS=windows -p:BuildTargetFramework=net11.0` failed because the repository's local shared-framework targeting pack has not been built (`eng/targetingpacks.targets(107,5)`). No successful test-project compilation is claimed. - The full `clr+libs` baseline and all test execution were not run. Windows service execution requires Windows. PR CI will provide build and runtime verification. # Risk <!-- Please assess the risk of taking this fix. Provide details backing up your assessment. --> Low: test-only, single-file, exact upstream patch; no product code, public APIs, or package changes. Successful handle acquisition preserves the existing path; the process-exit race no longer retains an incomplete Process and disposes the temporary object. # Package authoring no longer needed in .NET 9 IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version. Keep in mind that we still need package authoring in .NET 8 and older versions. > [!NOTE] > This backport and PR description were prepared with GitHub Copilot. Co-authored-by: Copilot App <[email protected]>
lewing
added a commit
that referenced
this pull request
Nov 20, 2026
…137930) Fixes Issue #136992 <!-- Issue Number --> main PR #137025 <!-- Link to PR if any that fixed this in the main branch. --> # Description <!-- Give a brief summary of the issue and how the pull request is fixing it. --> Test-only backport of 9ae326e. Keep the process local until its SafeHandle has been acquired, then assign it to the remote invocation handle. If the service process exits before handle acquisition, dispose the temporary Process and leave the remote invocation handle's Process unset. This prevents a later cleanup failure caused by storing a Process without an acquired handle. Only src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/WindowsServiceTester.cs changes; no product code changes or branch adaptations. # Customer Impact <!-- What is the impact to customers of not taking this fix? --> No shipped product behavior changes. Without this fix, Windows service tests can fail intermittently when the service exits during test-helper startup. # Regression <!-- Is this fixing a problem that was introduced in the most recent release, ie., fixing a regression? --> The same test-helper race exists on release/10.0. It has not been established as a regression introduced in the most recent release. # Testing <!-- What kind of testing has been done with the fix. --> - `dotnet build src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/Microsoft.Extensions.Hosting.WindowsServices.Tests.csproj --nologo -v:minimal` failed because the local shared-framework targeting pack has not been built. - `dotnet build src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/Microsoft.Extensions.Hosting.WindowsServices.Tests.csproj -p:UseLocalTargetingRuntimePack=false --nologo -v:minimal` passed on macOS, with zero warnings and zero errors, producing both net10.0-windows and net481 test assemblies. This is compile-only verification using SDK targeting packs and installed SDK 11.0.100-preview.6.26351.102 via the branch's allowed major roll-forward; it is not daily-runtime verification. - `git diff --check` passed. The stable patch ID matches the source commit. The full clr+libs baseline build was skipped for this test-only backport. No tests were executed locally, including Windows service tests, which require Windows. Windows runtime verification is deferred to PR CI. # Risk <!-- Please assess the risk of taking this fix. Provide details backing up your assessment. --> Low risk: an unchanged upstream fix confined to one test helper. The helper publishes a Process only after handle acquisition succeeds and disposes it on the process-exit race. No shipping code or public APIs change. # Package authoring no longer needed in .NET 9 IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version. Keep in mind that we still need package authoring in .NET 8 and older versions. Co-authored-by: MichalZ <[email protected]> Co-authored-by: Copilot App <[email protected]>
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.
Fix #136992
Precodnitions:
Race details:
Test failure: