Skip to content

Add more protection against exited processed in CoreclrTestLib#115642

Merged
hoyosjs merged 2 commits into
dotnet:mainfrom
jkotas:FindChildProcessesByName
May 16, 2025
Merged

Add more protection against exited processed in CoreclrTestLib#115642
hoyosjs merged 2 commits into
dotnet:mainfrom
jkotas:FindChildProcessesByName

Conversation

@jkotas

@jkotas jkotas commented May 16, 2025

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 16, 2025 06:48
@github-actions github-actions Bot added the area-Infrastructure-coreclr Only use for closed issues label May 16, 2025

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 enhances the robustness of process retrieval in CoreclrTestLib by adding protection against exceptions when processes exit unexpectedly and updating the logging mechanism.

  • Use TryGetProcessName and TryGetProcessId for logging process details
  • Wrap GetChildren() calls in try-catch blocks to handle process exit exceptions
  • Update logging output for active processes
Comments suppressed due to low confidence (2)

src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs:684

  • TryGetProcessName is used with an output type of int for parentProcessName, which is inconsistent with typical process name types that are strings. Please verify if this is intended or update the type to string.
process.TryGetProcessName(out int parentProcessName);

src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs:864

  • TryGetProcessName outputs a string for activeProcessName here, which is inconsistent with its usage earlier where an int was expected; please ensure both usages align with the correct process name type.
activeProcess.TryGetProcessName(out string activeProcessName);

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

@jkotas

jkotas commented May 16, 2025

Copy link
Copy Markdown
Member Author

Continuation of #113937

Motivate by failure seen in #115602

Xunit.Sdk.FailException: Test Infrastructure Failure: System.InvalidOperationException: Process has exited, so the requested information is not available.
   at System.Diagnostics.Process.EnsureState(State state) in /_/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs:line 987
   at System.Diagnostics.Process.get_ProcessName() in /_/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs:line 913
   at CoreclrTestLib.CoreclrTestWrapperLib.FindChildProcessesByName(Process process, String childName)
   at CoreclrTestLib.CoreclrTestWrapperLib.RunTest(String executable, String outputFile, String errorFile, String category, String testBinaryBase, String outputDir)
   at TestLibrary.OutOfProcessTest.RunOutOfProcessTest(String assemblyPath, String testPathPrefix)
   at Xunit.Assert.Fail(String message) in /_/src/arcade/src/Microsoft.DotNet.XUnitAssert/src/FailAsserts.cs:line 38
   at TestLibrary.OutOfProcessTest.RunOutOfProcessTest(String assemblyPath, String testPathPrefix)
   at Program.<<Main>$>g__TestExecutor142|0_143(StreamWriter tempLogSw, StreamWriter statsCsvSw, <>c__DisplayClass0_0&)
22:30:19.821 Failed test: baseservices/exceptions/unhandled/unhandledTester/unhandledTester.cmd

@jkotas jkotas requested review from hoyosjs and jkoritzinsky May 16, 2025 06:51
Comment thread src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs Outdated
@hoyosjs hoyosjs enabled auto-merge (squash) May 16, 2025 17:02
@hoyosjs hoyosjs merged commit 9579c58 into dotnet:main May 16, 2025
72 checks passed
@jkotas jkotas deleted the FindChildProcessesByName branch May 27, 2025 21:20
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Infrastructure-coreclr Only use for closed issues

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants