Stabilize the SOS test harness across platforms - #6000
Open
steveisok wants to merge 1 commit into
Open
Conversation
This was referenced Sep 2, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
steveisok
force-pushed
the
steveisok-sos-harness-stabilization-layer
branch
from
September 3, 2026 12:22
deafb71 to
d6e93e0
Compare
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
BoundedProcess.DrainOutput can throw when accessing Process.ExitCode during timeout-kill teardown, masking the intended timeout/failure diagnostics.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/tests/SOS.TestHarness/BoundedProcess.cs — DrainOutput assumes the process has an ExitCode, but in the timeout-kill path Terminate() only… |
What changed in this PR
This PR strengthens the SOS test harness’ cross-platform stability by introducing bounded child-process execution/drainage, tightening host pooling behavior, improving failure diagnostics, and making debuggee builds more RID/arch aware to reduce platform-specific flakes.
Changes:
- Introduce
BoundedProcessand migrate dump/capture call sites to bounded execution with concurrent stdout/stderr drainage. - Bound and pool resource-heavy dump hosts (LLDB + dotnet-dump), add clearer host/engine failure reporting, and improve LLDB/macOS integration.
- Add configuration validity/unit tests and make debuggee build outputs more RID/arch aware (including prebuilding net462 debuggees on Windows).
| File | Description |
|---|---|
| src/tests/SOS.UnitTests/Debuggees/SosHarnessScenarios/TestHarness.cs | Switch self-snapshotting to BoundedProcess to avoid hangs and improve error detail. |
| src/tests/SOS.UnitTests/Debuggees/SosHarnessScenarios/SosHarnessScenarios.csproj | Link BoundedProcess.cs into the debuggee for non-desktop TFMs. |
| src/tests/SOS.UnitTests/Debuggees/Directory.Build.props | Set a RID-aware default apphost runtime identifier for cross-target legs. |
| src/tests/SOS.Tests/TestConfigValidityTests.cs | Add unit tests for platform/config validity helpers and known failure classification. |
| src/tests/SOS.Tests/HostSlotTests.cs | Add tests for host-slot eviction and failure recovery behavior. |
| src/tests/SOS.Tests/BoundedProcessTests.cs | Add Linux-focused tests for concurrent drainage and process-group timeout handling. |
| src/tests/SOS.TestHarness/ToolPaths.cs | Prefer macOS sos-lldb, add harness-specific overrides, and add Xcode framework resolution + host runtime override. |
| src/tests/SOS.TestHarness/TestConfig.cs | Centralize additional validity constraints and expose helpers for test validation. |
| src/tests/SOS.TestHarness/Targets.cs | Ensure pooled host teardown covers LLDB as well as dotnet-dump. |
| src/tests/SOS.TestHarness/SOS.TestHarness.csproj | Add InternalsVisibleTo for the new SOS.Tests test project. |
| src/tests/SOS.TestHarness/SnapshotStore.cs | Use bounded execution for capture paths, add known-createdump-permission failure handling, and make debuggee builds RID/arch aware. |
| src/tests/SOS.TestHarness/RepoLayout.cs | Add a path helper for prebuilt net462 debuggee output. |
| src/tests/SOS.TestHarness/LldbLiveHost.cs | Add macOS-specific env var to keep debuggee exception mode consistent under LLDB. |
| src/tests/SOS.TestHarness/LldbHostBase.cs | Improve macOS LLDB environment setup and make stdout/stderr drainage/joining more robust. |
| src/tests/SOS.TestHarness/HostSlot.cs | Add a dedicated LLDB slot and strengthen host open/close behavior around failures. |
| src/tests/SOS.TestHarness/DumpSession.cs | Pool LLDB dump sessions via a capacity-1 slot similarly to dotnet-dump. |
| src/tests/SOS.TestHarness/DbgEngLiveHost.cs | Treat only second-chance exceptions as crash breaks for live dbgeng runs. |
| src/tests/SOS.TestHarness/DbgEngCapturer.cs | Require second-chance exception breaks when capturing crash dumps. |
| src/tests/SOS.TestHarness/ChildEngineClient.cs | Improve error reporting when EngineHost exits early and preserve stderr for diagnostics. |
| src/tests/SOS.TestHarness/BoundedProcess.cs | Add bounded, cross-platform process runner with optional Linux process-group isolation. |
| src/tests/dirs.proj | Pass TargetRid into debuggee build orchestration. |
| src/tests/Debuggees.proj | Add Windows net462 debuggee build target (with x86 support) and select applicable projects. |
| src/SOS/Strike/util.cpp | Fix SOS version info validation to check the queried version struct. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+76
to
+95
| private static BoundedProcessResult DrainOutput( | ||
| Process process, | ||
| Task<string> stdoutTask, | ||
| Task<string> stderrTask, | ||
| string command, | ||
| TimeSpan timeout) | ||
| { | ||
| Task outputTask = Task.WhenAll(stdoutTask, stderrTask); | ||
| if (!outputTask.Wait(timeout)) | ||
| { | ||
| throw new TimeoutException( | ||
| $"'{command}' exited with code {process.ExitCode}, but its redirected output did not close " + | ||
| $"within {timeout}."); | ||
| } | ||
|
|
||
| return new BoundedProcessResult( | ||
| process.ExitCode, | ||
| stdoutTask.GetAwaiter().GetResult(), | ||
| stderrTask.GetAwaiter().GetResult()); | ||
| } |
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.

Stack layer 2 of the native decomposition for #5981.
Depends on #5999
This layer stabilizes the reusable SOS harness across hosts and architectures: bounded child-process capture and stream drainage, clearer child-host failures, bounded LLDB dump hosts, second-chance DbgEng crash handling, macOS
sos-lldbintegration, RID-aware debuggee builds, and focused platform/configuration validity checks.It intentionally excludes Helix submission and pipeline wiring, payload overlays, sharding, command-coverage migration, and legacy test deletion.
Validation:
dotnet build src/tests/SOS.Tests/SOS.Tests.csproj -c Debug -p:TargetArch=arm64 -p:TargetRid=osx-arm64 --no-restoreBoundedProcessTests,HostSlotTests, andTestConfigValidityTests(20 passed)dotnet publishfor theSosHarnessScenariossingle-fileosx-arm64debuggee./build.sh -skipmanaged -configuration Debug -architecture arm64