Repository navigation
Add SOS interpreter-frame test infrastructure - #5829
max-charlamb merged 7 commits into
Conversation
Adds an opt-in SOS test that exercises CoreCLR interpreter-frame stack walking. The test is skipped by default and unskips when SOS_TEST_INTERPRETER is set; FEATURE_INTERPRETER is only available in Debug/Checked CoreCLR drops, so a normal SOS test run cannot exercise it. * New SOSInterpreterTests.InterpreterStackTest test method, debuggee, and script that VERIFY ClrStack output contains the runtime's [InterpreterFrame: <hex>] sentinel and the user methods executing under it. * SOSRunner sets DOTNET_Interpreter=InterpTestMethod* on the debuggee in both the createdump-launch and debugger-spawned-debuggee paths when config.TestInterpreter is true (mirrors the TestCDAC pattern). * Convention: methods in interpreter-test debuggees that should be interpreted are named with the InterpTestMethod prefix. * Shared Debuggees/Directory.Build.targets handles the per-debuggee opt-in: csproj sets <InterpreterTest>true</InterpreterTest>; when SOS_TEST_INTERPRETER is unset the build no-ops via a BuildDependsOn redirect with a clear message; when set the runtimeconfig forward-compat option is emitted. * eng/build.ps1 / eng/build.sh: -testInterpreter switch sets the env var. * eng/testsosinterpreter.cmd|.sh: convenience runners filtered to SOSInterpreterTests. Co-authored-by: Copilot <[email protected]>
The Live phase relies on a 2nd-chance SEH escalation that the interpreter's unhandled-exception path does not currently produce — cdb only sees first-chance e0434352 and the process exits cleanly before any SOS commands can run. The createdump path is unaffected: the runtime's UnhandledExceptionFilter invokes createdump in-process before exit and produces a valid minidump for SOS analysis, with interpreter frames and the [InterpreterFrame:] sentinel present. Set TestLive = false and pin DumpGenerator = CreateDump so the test exercises only the working path. Verified passing end-to-end against a Checked CoreCLR overlay. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds an opt-in SOS.UnitTests scenario to validate CoreCLR interpreter-frame stack walking by running an interpreter-touched debuggee, generating a dump, and verifying !ClrStack output contains the [InterpreterFrame: <hex>] sentinel plus expected managed frames. This is gated behind SOS_TEST_INTERPRETER=true and build/test runner switches so it’s skipped by default.
Changes:
- Adds a new
SOSInterpreterTests.InterpreterStackTest+ script + debuggee to assert interpreter-frame stack walking in dump analysis. - Introduces interpreter-test gating/plumbing via
SOS_TEST_INTERPRETER,TestConfiguration.TestInterpreter, and settingDOTNET_Interpreter=InterpTestMethod*when enabled. - Adds convenience runners and
-testInterpreterbuild switches for turning the scenario on.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/SOS.UnitTests/SOSRunner.cs | Sets DOTNET_Interpreter env var when config.TestInterpreter is enabled (debuggee launch + debugger-spawn paths). |
| src/tests/SOS.UnitTests/SOS.cs | Adds SOSInterpreterTests test entrypoint and forces dump-only execution. |
| src/tests/SOS.UnitTests/Scripts/InterpreterStackTest.script | New script validating !PrintException and !ClrStack contains [InterpreterFrame:] and expected methods. |
| src/tests/SOS.UnitTests/Debuggees/InterpreterStackTest/InterpreterUserHelper.cs | New helper methods intended to be executed under the interpreter. |
| src/tests/SOS.UnitTests/Debuggees/InterpreterStackTest/InterpreterStackTest.csproj | New debuggee project opting into interpreter-test behavior. |
| src/tests/SOS.UnitTests/Debuggees/InterpreterStackTest/InterpreterStackTest.cs | New debuggee Main that triggers an exception through interpreted frames. |
| src/tests/SOS.UnitTests/Debuggees/Directory.Build.targets | New shared MSBuild gating/infrastructure for interpreter-test debuggee builds. |
| src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs | Adds TestInterpreter flag (from SOS_TEST_INTERPRETER) and tags log suffixes with .interpreter. |
| eng/testsosinterpreter.sh | New convenience runner enabling interpreter tests on Unix. |
| eng/testsosinterpreter.cmd | New convenience runner enabling interpreter tests on Windows. |
| eng/build.sh | Adds -testInterpreter argument to export SOS_TEST_INTERPRETER=true during -test runs. |
| eng/build.ps1 | Adds -testInterpreter switch to export SOS_TEST_INTERPRETER=true during -test runs. |
| documentation/privatebuildtesting.md | Documents how to enable/run interpreter-frame tests with private runtime overlays. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The new src/tests/SOS.UnitTests/Debuggees/Directory.Build.targets shadows the parent Directory.Build.targets chain (src/tests -> src), which imports the Arcade SDK targets via the root src/Directory.Build.targets. Without those imports, /t:Test invocation on every debuggee csproj fails with MSB4057 'The target Test does not exist in the project' because Arcade's filtering for non-test projects no longer applies. Add an explicit import of ..\..\Directory.Build.targets to re-establish the chain. This is the same pattern src/tests/Directory.Build.targets uses to import src/Directory.Build.targets. Co-authored-by: Copilot <[email protected]>
Adds an opt-in Interpreter SOS test leg to runtime-diagnostics.yml that
exercises the diagnostics-side SOSInterpreterTests against a Checked CoreCLR
drop. FEATURE_INTERPRETER is only compiled into Debug/Checked CoreCLR, so the
existing Release build leg cannot run this test.
Changes:
* eng/pipelines/diagnostics/runtime-diag-job.yml: adds a testInterpreter
parameter (default false). When true, _TestInterpreterArgs resolves to
-testInterpreter and is forwarded to the diagnostics build script alongside
the existing -useCdac / -noFallback flags. Default-false invocation is
identical to today.
* eng/pipelines/runtime-diagnostics.yml:
- New build leg that produces a Checked CoreCLR (libs/SDK stay Release) under
a distinct artifact name (..._coreclr_Checked).
- New Interpreter test job that depends on the Checked build leg, downloads
its artifact, and is the only job that sets testInterpreter: true.
- The cDAC / cDAC_no_fallback / DAC test jobs and the existing Release build
leg are unchanged.
Tested with a manual ADO queue using diagnosticsBranch pointed at the
companion diagnostics PR (dotnet/diagnostics#5829).
Co-authored-by: Copilot <[email protected]>
Adds an opt-in Interpreter SOS test leg to runtime-diagnostics.yml that
exercises the diagnostics-side SOSInterpreterTests against a Checked CoreCLR
drop. FEATURE_INTERPRETER is only compiled into Debug/Checked CoreCLR, so the
existing Release build leg cannot run this test.
Changes:
* eng/pipelines/diagnostics/runtime-diag-job.yml: adds a testInterpreter
parameter (default false). When true, _TestInterpreterArgs resolves to
-testInterpreter and is forwarded to the diagnostics build script alongside
the existing -useCdac / -noFallback flags. Default-false invocation is
identical to today.
* eng/pipelines/runtime-diagnostics.yml:
- New build leg that produces a Checked CoreCLR (libs/SDK stay Release) under
a distinct artifact name (..._coreclr_Checked).
- New Interpreter test job that depends on the Checked build leg, downloads
its artifact, and is the only job that sets testInterpreter: true.
- The cDAC / cDAC_no_fallback / DAC test jobs and the existing Release build
leg are unchanged.
Tested with a manual ADO queue using diagnosticsBranch pointed at the
companion diagnostics PR (dotnet/diagnostics#5829).
Co-authored-by: Copilot <[email protected]>
Adds an opt-in Interpreter SOS test leg to runtime-diagnostics.yml that
exercises the diagnostics-side SOSInterpreterTests against a Checked CoreCLR
drop. FEATURE_INTERPRETER is only compiled into Debug/Checked CoreCLR, so the
existing Release build leg cannot run this test.
Changes:
* eng/pipelines/diagnostics/runtime-diag-job.yml: adds a testInterpreter
parameter (default false). When true, _TestInterpreterArgs resolves to
-testInterpreter and is forwarded to the diagnostics build script alongside
the existing -useCdac / -noFallback flags. Default-false invocation is
identical to today.
* eng/pipelines/runtime-diagnostics.yml:
- New build leg that produces a Checked CoreCLR (libs/SDK stay Release) under
a distinct artifact name (..._coreclr_Checked).
- New Interpreter test job that depends on the Checked build leg, downloads
its artifact, and is the only job that sets testInterpreter: true.
- The cDAC / cDAC_no_fallback / DAC test jobs and the existing Release build
leg are unchanged.
Tested with a manual ADO queue using diagnosticsBranch pointed at the
companion diagnostics PR (dotnet/diagnostics#5829).
Co-authored-by: Copilot <[email protected]>
Adds an opt-in Interpreter SOS test leg to runtime-diagnostics.yml that
exercises the diagnostics-side SOSInterpreterTests against a Checked CoreCLR
drop. FEATURE_INTERPRETER is only compiled into Debug/Checked CoreCLR, so the
existing Release build leg cannot run this test.
Changes:
* eng/pipelines/diagnostics/runtime-diag-job.yml: adds a testInterpreter
parameter (default false). When true, _TestInterpreterArgs resolves to
-testInterpreter and is forwarded to the diagnostics build script alongside
the existing -useCdac / -noFallback flags. Default-false invocation is
identical to today.
* eng/pipelines/runtime-diagnostics.yml:
- New build leg that produces a Checked CoreCLR (libs/SDK stay Release) under
a distinct artifact name (..._coreclr_Checked).
- New Interpreter test job that depends on the Checked build leg, downloads
its artifact, and is the only job that sets testInterpreter: true.
- The cDAC / cDAC_no_fallback / DAC test jobs and the existing Release build
leg are unchanged.
Tested with a manual ADO queue using diagnosticsBranch pointed at the
companion diagnostics PR (dotnet/diagnostics#5829).
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
- Consolidate InterpreterStackTest into a single source file. - Add InterpreterStackInterleavedTest, which exercises an interp -> JIT -> interp call stack via a separate Trampoline assembly (the per-module interpreter selection keeps Trampoline JIT'd while the test methods are interpreted). - build.sln: add only the three new project entries (no SlnGen-driven reordering of unrelated entries). Co-authored-by: Copilot <[email protected]>
b3b32ec to
a4dd5d7
Compare
|
Successful run on runtime-diagnostics: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1413862&view=results |
Adds an opt-in Interpreter SOS test leg to runtime-diagnostics.yml that
exercises the diagnostics-side SOSInterpreterTests against a Checked CoreCLR
drop. FEATURE_INTERPRETER is only compiled into Debug/Checked CoreCLR, so the
existing Release build leg cannot run this test.
Changes:
* eng/pipelines/diagnostics/runtime-diag-job.yml: adds a testInterpreter
parameter (default false). When true, _TestInterpreterArgs resolves to
-testInterpreter and is forwarded to the diagnostics build script alongside
the existing -useCdac / -noFallback flags. Default-false invocation is
identical to today.
* eng/pipelines/runtime-diagnostics.yml:
- New build leg that produces a Checked CoreCLR (libs/SDK stay Release) under
a distinct artifact name (..._coreclr_Checked).
- New Interpreter test job that depends on the Checked build leg, downloads
its artifact, and is the only job that sets testInterpreter: true.
- The cDAC / cDAC_no_fallback / DAC test jobs and the existing Release build
leg are unchanged.
Tested with a manual ADO queue using diagnosticsBranch pointed at the
companion diagnostics PR (dotnet/diagnostics#5829).
Co-authored-by: Copilot <[email protected]>
Adds an opt-in Interpreter SOS test leg to runtime-diagnostics.yml that
exercises the diagnostics-side SOSInterpreterTests against a Checked CoreCLR
drop. FEATURE_INTERPRETER is only compiled into Debug/Checked CoreCLR, so the
existing Release build leg cannot run this test.
Changes:
* eng/pipelines/diagnostics/runtime-diag-job.yml: adds a testInterpreter
parameter (default false). When true, _TestInterpreterArgs resolves to
-testInterpreter and is forwarded to the diagnostics build script alongside
the existing -useCdac / -noFallback flags. Default-false invocation is
identical to today.
* eng/pipelines/runtime-diagnostics.yml:
- New build leg that produces a Checked CoreCLR (libs/SDK stay Release) under
a distinct artifact name (..._coreclr_Checked).
- New Interpreter test job that depends on the Checked build leg, downloads
its artifact, and is the only job that sets testInterpreter: true.
- The cDAC / cDAC_no_fallback / DAC test jobs and the existing Release build
leg are unchanged.
Tested with a manual ADO queue using diagnosticsBranch pointed at the
companion diagnostics PR (dotnet/diagnostics#5829).
Co-authored-by: Copilot <[email protected]>
Summary
Adds an opt-in SOS test that exercises CoreCLR interpreter-frame stack walking. The test is skipped by default and unskips only when
SOS_TEST_INTERPRETERis set;FEATURE_INTERPRETERis only available in Debug/Checked CoreCLR drops, so a normal SOS test run cannot exercise it. Seedocumentation/privatebuildtesting.mdfor how to enable.What the test verifies
The script asserts that
!ClrStackagainst an interpreter-touched dump shows the runtime's[InterpreterFrame: <hex>]sentinel and the user methods running under it (InterpreterUserHelper.InterpTestMethod*plusInterpreterStackTestApp.Main). The[InterpreterFrame:]line is the unique signal for interpreter activation, so a Release runtime or a runtime where the env var didn't take effect would fail rather than silently pass.How activation works
<InterpreterTest>true</InterpreterTest>. The sharedDebuggees/Directory.Build.targetshandles everything else. Methods that should run on the interpreter follow the convention of being named with the prefixInterpTestMethod; the shared targets pin the runtime knob toInterpTestMethod*.SOS_TEST_INTERPRETER=true(or-testInterpretertoeng\build.cmd/eng/build.sh) unskipsSOSInterpreterTests.InterpreterStackTestand triggersSOSRunnerto setDOTNET_Interpreter=InterpTestMethod*on the debuggee in both the createdump-launch path and the debugger-spawned-debuggee path (mirrors the existingTestCDACpattern at the same two sites).InterpreterTest=truebutSOS_TEST_INTERPRETERis unset, aBuildDependsOnredirect makes the build no-op with a clear message — the binary that comes out would not actually exercise the interpreter, so we don't produce one.Files
Debuggees/InterpreterStackTest/— debuggeeDebuggees/Directory.Build.targets— shared interpreter-test infrastructureScripts/InterpreterStackTest.script— verify!PrintException+!ClrStackeng/testsosinterpreter.cmd|.sh— convenience runnersTestConfiguration.cs,SOSRunner.cs,SOS.cs,eng/build.ps1|.sh,documentation/privatebuildtesting.mdVerified
SOS_TEST_INTERPRETERunset, the test skips with a clear message;SOS.UnitTestsbuilds clean..dotnet-test, the test passes (15s, dump-only path).Why dump-only (TestLive=false)
The Live phase relies on second-chance SEH escalation. Today, interpreter-touched call chains do not escalate unhandled exceptions to second-chance — cdb sees only first-chance
e0434352and the process exits cleanly before any SOS commands can run.createdumpis unaffected: the runtime's UnhandledExceptionFilter invokes it in-process before exit and produces a valid minidump. We pin toDumpGenerator.CreateDumpand skip Live; this is also the more useful path for cDAC stack-walk validation. The Live phase can be re-enabled if/when the runtime side fixes the 2nd-chance gap; no diagnostics-side changes would be required.See successful run with interpreter in the cDAC: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1412907&view=ms.vss-test-web.build-test-results-tab&runId=39312036&resultId=100018&paneView=debug