Skip to content

Add more protection against exited processed in CoreclrTestLib #115642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2025

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented May 16, 2025

No description provided.

@Copilot Copilot AI review requested due to automatic review settings May 16, 2025 06:48
Copy link
Contributor

@Copilot Copilot AI left a comment

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);

Copy link
Contributor

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

@jkotas
Copy link
Member Author

jkotas commented May 16, 2025

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
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants