Disable EnsureEnvironmentExitDoesntHang on .NET Framework#125912
Merged
danmoseley merged 2 commits intomainfrom Mar 23, 2026
Merged
Disable EnsureEnvironmentExitDoesntHang on .NET Framework#125912danmoseley merged 2 commits intomainfrom
danmoseley merged 2 commits intomainfrom
Conversation
…down issue Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/2454ed8d-3ded-4ba4-a49a-d52492d4ff51
Copilot
AI
changed the title
[WIP] Fix EnsureEnvironmentExitDoesntHang test for .NET Framework
Disable EnsureEnvironmentExitDoesntHang on .NET Framework
Mar 22, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/area-extensions-hosting |
danmoseley
approved these changes
Mar 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR disables ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang when running on .NET Framework due to a known shutdown/finalization limitation that can cause an unhandled exception during process teardown, making the test unreliable in that target.
Changes:
- Added a
.NET Framework-specific skip toEnsureEnvironmentExitDoesntHang. - Simplified the expected exit code logic by inlining the non-.NET-Framework expected exit code (
125).
jkotas
approved these changes
Mar 22, 2026
Member
jkotas
left a comment
There was a problem hiding this comment.
Looks fine to me.
cc @dotnet/area-extensions-hosting @mrek-msft for awareness
Member
|
stephentoub
reviewed
Mar 23, 2026
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/ConsoleLifetimeExitTests.cs
Show resolved
Hide resolved
stephentoub
approved these changes
Mar 23, 2026
eiriktsarpalis
pushed a commit
that referenced
this pull request
Mar 23, 2026
`ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang` fails on .NET Framework because `System.Console.ControlCHooker.Unhook()` throws `IOException: The parameter is incorrect` during process finalization, causing an unhandled exception (exit code -532462766 / EXCEPTION_COMPLUS). This is a known .NET Framework shutdown limitation. ## Changes - Added `[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "NET Framework shutdown issue")]` to `EnsureEnvironmentExitDoesntHang` — consistent with the existing skip on the related `EnsureEnvironmentExitCode` test - Simplified the test body: removed the now-dead `expectedExitCode = PlatformDetection.IsNetFramework ? 0 : 125` conditional, inlining `125` directly > [!NOTE] > This PR description was generated with AI assistance (GitHub Copilot). <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> ---- *This section details on the original issue you should resolve* <issue_title>Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang fails on .NET Framework</issue_title> <issue_description>## Build Information Build: https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=1143743 Build error leg or test failing: Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang Pull request: #119515 Console excerpt: ``` Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang [FAIL] Microsoft.DotNet.RemoteExecutor.RemoteExecutionException : Exit code was -532462766 but it should have been 0 Stack Trace: /_/src/arcade/src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeHandle.cs(242,0): at Microsoft.DotNet.RemoteExecutor.RemoteInvokeHandle.Dispose(Boolean disposing) /_/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/ConsoleLifetimeExitTests.cs(223,0): at Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang() ``` -532462766 corresponds with EXCEPTION_COMPLUS. ```json { "ErrorMessage": "ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang [FAIL]", "ErrorPattern": "", "BuildRetry": false, "ExcludeConsoleLog": false } ``` <!-- Known issue validation start --> ### Known issue validation **Build: 🔎** https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743 **Error message validated:** `[Microsoft\.DotNet\.RemoteExecutor\.RemoteExecutionException : Exit code was -532462766 but it should have been 0.*EnsureEnvironmentExitDoesntHang()`] **Result validation:** ❌ Known issue did not match with the provided build. **Validation performed at:** 9/10/2025 6:12:29 PM UTC <!-- Known issue validation end --> <!-- Known issue validation start --> ### Known issue validation **Build: 🔎** https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743 **Error message validated:** `[Microsoft.DotNet.RemoteExecutor.RemoteExecutionException : Exit code was -532462766 but it should have been 0`] **Result validation:** ✅ Known issue matched with the provided build. **Validation performed at:** 9/10/2025 7:05:39 PM UTC <!-- Known issue validation end --> <!--Known issue error report start --> ### Report |Build|Definition|Test|Pull Request| |---|---|---|---| |[1143743](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743)|dotnet/runtime|[Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743&view=ms.vss-test-web.build-test-results-tab&runId=31540798&resultId=103521)|dotnet/runtime#119515| #### Summary |24-Hour Hit Count|7-Day Hit Count|1-Month Count| |---|---|---| |1|1|1| <!--Known issue error report end --> <!-- Known issue validation start --> ### Known issue validation **Build: 🔎** https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743 **Error message validated:** `[at System.Console.ControlCHooker.Unhook`] **Result validation:** ✅ Known issue matched with the provided build. **Validation performed at:** 9/10/2025 7:07:38 PM UTC <!-- Known issue validation end --> <!--Known issue error report start --> ### Report |Build|Definition|Test|Pull Request| |---|---|---|---| |[1143743](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743)|dotnet/runtime|[Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743&view=ms.vss-test-web.build-test-results-tab&runId=31540798&resultId=103521)|dotnet/runtime#119515| #### Summary |24-Hour Hit Count|7-Day Hit Count|1-Month Count| |---|---|---| |1|1|1| <!--Known issue error report end --> <!--Known issue error report start --> ### Report |Build|Definition|Test|Pull Request| |---|---|---|---| |[1174378](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1174378)|dotnet/runtime|[Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1174378&view=ms.vss-test-web.build-test-results-tab&runId=32501172&resultId=104197)|| |[1170349](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1170349)|dotnet/runtime|[Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1170349&view=ms.vss-test-web.build-test-results-tab&runId=32385630&resultId=103595)|dotnet/runtime#120603| |[1169444](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1169444)|dotnet/runtime|[Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitT... </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #119545 <!-- START COPILOT CODING AGENT TIPS --> --- ⌨️ Start Copilot coding agent tasks without leaving your editor — available in [VS Code](https://gh.io/cca-vs-code-docs), [Visual Studio](https://gh.io/cca-visual-studio-docs), [JetBrains IDEs](https://gh.io/cca-jetbrains-docs) and [Eclipse](https://gh.io/cca-eclipse-docs). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: danmoseley <6385855+danmoseley@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.
ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHangfails on .NET Framework becauseSystem.Console.ControlCHooker.Unhook()throwsIOException: The parameter is incorrectduring process finalization, causing an unhandled exception (exit code -532462766 / EXCEPTION_COMPLUS). This is a known .NET Framework shutdown limitation.Changes
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "NET Framework shutdown issue")]toEnsureEnvironmentExitDoesntHang— consistent with the existing skip on the relatedEnsureEnvironmentExitCodetestexpectedExitCode = PlatformDetection.IsNetFramework ? 0 : 125conditional, inlining125directlyNote
This PR description was generated with AI assistance (GitHub Copilot).
Original prompt
This section details on the original issue you should resolve
<issue_title>Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang fails on .NET Framework</issue_title>
<issue_description>## Build Information
Build: https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=1143743
Build error leg or test failing: Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang
Pull request: #119515
Console excerpt:
-532462766 corresponds with EXCEPTION_COMPLUS.
{ "ErrorMessage": "ConsoleLifetimeExitTests.EnsureEnvironmentExitDoesntHang [FAIL]", "ErrorPattern": "", "BuildRetry": false, "ExcludeConsoleLog": false }Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743
Error message validated:
[Microsoft\.DotNet\.RemoteExecutor\.RemoteExecutionException : Exit code was -532462766 but it should have been 0.*EnsureEnvironmentExitDoesntHang()]Result validation: ❌ Known issue did not match with the provided build.
Validation performed at: 9/10/2025 6:12:29 PM UTC
Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743
Error message validated:
[Microsoft.DotNet.RemoteExecutor.RemoteExecutionException : Exit code was -532462766 but it should have been 0]Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 9/10/2025 7:05:39 PM UTC
Report
Summary
Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1143743
Error message validated:
[at System.Console.ControlCHooker.Unhook]Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 9/10/2025 7:07:38 PM UTC
Report
Summary
Report
⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.