Fix issue in Collect-linux probing where process may have exited between enumeration and usage.#5778
Merged
hoyosjs merged 1 commit intodotnet:mainfrom Mar 25, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to stabilize dotnet-trace collect-linux --probe on Linux by handling the case where a target process exits between being enumerated and being probed, addressing intermittent failures like those reported in #5776.
Changes:
- Add exception handling around per-process probing during
--probeenumeration to skip processes that disappear mid-probe.
Comments suppressed due to low confidence (1)
src/Tools/dotnet-trace/CommandLine/Commands/CollectLinuxCommand.cs:268
- The new try/catch introduces a scoping/compilation issue:
supports,resolvedPid,resolvedName, anddetectedRuntimeVersionare declared inside thetryblock but are used afterward (e.g., inBuildProcessSupportCsv(...)and theif (supports)block). This won’t compile. Consider either (1) declaring these variables before thetryand assigning within it, or (2) movingBuildProcessSupportCsvand the subsequentif/elselogic inside thetryblock.
Also, since ex isn’t used other than the filter, you can simplify by using separate catch (DiagnosticToolException) / catch (DiagnosticsClientException) blocks instead of catch (Exception ex) when ....
try
{
bool supports = ProcessSupportsUserEventsIpcCommand(pid, string.Empty, out int resolvedPid, out string resolvedName, out string detectedRuntimeVersion);
}
catch (Exception ex) when (ex is DiagnosticToolException or DiagnosticsClientException)
{
// Process may have exited between enumeration and probing — skip it.
continue;
}
BuildProcessSupportCsv(resolvedPid, resolvedName, supports, supportedCsv, unsupportedCsv);
if (supports)
{
supportedProcesses.AppendLine($"{resolvedPid} {resolvedName}");
}
else
{
unsupportedProcesses.AppendLine($"{resolvedPid} {resolvedName} - Detected runtime: '{detectedRuntimeVersion}'");
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…een enumeration and usage.
cc64db7 to
9853085
Compare
noahfalk
approved these changes
Mar 25, 2026
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 #5776
Fixes issues seen in CollectLinuxCommand_Probe_ListsProcesses_WhenNoArgs and CollectLinuxCommand_Probe_Csv