Skip to content

Enable cDAC-only dump analysis mode and add CI test legs#5755

Draft
max-charlamb wants to merge 8 commits intodotnet:mainfrom
max-charlamb:cdac-only-testing
Draft

Enable cDAC-only dump analysis mode and add CI test legs#5755
max-charlamb wants to merge 8 commits intodotnet:mainfrom
max-charlamb:cdac-only-testing

Conversation

@max-charlamb
Copy link
Copy Markdown
Member

Summary

Enable SOS to load and operate on dumps using only the cDAC (no legacy DAC dependency). This enables cross-platform dump analysis and provides CI coverage for cDAC-only mode.

Changes

Commit 1: Enable cDAC-only dump analysis mode

When ForceUseContractReader is set (via runtimes --forceusecdac):

  • RuntimeWrapper: tries cDAC even when caller doesn't pass UseCDac flag, and skips legacy DAC fallback
  • DumpTargetFactory: allows cross-platform dump analysis (the cDAC is a host-native NativeAOT binary)
  • Runtime.GetLibraryPath: skips platform filter for DebugLibraryKind.CDac
  • Runtime.GetLocalPath: falls back to RuntimeModuleDirectory for cDAC, enabling user-provided paths via setclrpath

Commit 2: Remove outdated CDACCompatible test scripts

The testsoscdac.cmd/sh scripts filtered by CDACCompatible category, but no tests were ever marked with this trait.

Commit 3: Add cDAC-only CI test legs

  • SOSRunner sends runtimes --forceusecdac to dotnet-dump when SOS_TEST_CDAC is set
  • build.yml gains a useCdac parameter that passes -useCdac to the build script
  • Add Windows_cDAC (build+test) and Ubuntu_22_04_cDAC (test-only) CI legs running Release x64

Testing

Verified locally with dotnet-dump analyze using cDAC-only mode against runtime cDAC dump test fixtures:

  • clrstack — full managed stack trace ✅
  • threads — lists all threads ✅
  • dumpheap -stat — graceful error (cDAC feature gap in ClrMD, tracked separately) ✅

Related

@max-charlamb max-charlamb force-pushed the cdac-only-testing branch 2 times, most recently from 65cd2f6 to bd67374 Compare March 11, 2026 20:50
Max Charlamb and others added 3 commits April 3, 2026 14:35
When ForceUseContractReader is set:
- RuntimeWrapper.GetClrDataProcess() tries cDAC even when caller
  doesn't pass UseCDac flag, and skips legacy DAC fallback.
- DumpTargetFactory.OpenDump() allows cross-platform dump analysis
  since the cDAC is a host-native NativeAOT binary.
- Runtime.GetLibraryPath() skips platform filter for cDAC discovery.
- Runtime.GetLocalPath() falls back to RuntimeModuleDirectory for
  cDAC, enabling user-provided paths via setclrpath.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The testsoscdac.cmd/sh scripts filtered tests by CDACCompatible
category, but no tests were ever marked with this trait. Replace
with the new SOS_TEST_CDAC environment variable approach that
enables cDAC-only mode for all dotnet-dump tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- SOSRunner sends 'runtimes --forceusecdac' to dotnet-dump when
  SOS_TEST_CDAC is set, enabling cDAC-only mode for dump tests.
- build.yml gains a useCdac parameter that passes -useCdac to
  the build script, setting SOS_TEST_CDAC=true.
- Add Windows_cDAC (build+test) and Ubuntu_22_04_cDAC (test-only)
  CI legs running Release x64 with cDAC-only mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
max-charlamb and others added 5 commits April 8, 2026 18:46
- Skip live and native debugger (cdb/lldb) tests in cDAC mode; only run
  dotnet-dump dump analysis path where forceusecdac is supported
- Wire up PackageWithCDac=true when -useCdac is passed so the cDAC
  transport NuGet package is downloaded and mscordaccore_universal is
  included in dotnet-dump publish output
- When native build is skipped (test-only legs), run native-prereqs
  separately to download the cDAC transport package
- Add RID subdirectory resolution for cDAC path lookup since
  sos-packaging.props places native binaries under win-x64/ etc.
- Add shared framework directory fallback for cDAC path resolution

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add SEH protection around FormatGeneratedException calls to prevent
access violations in GetLineByOffset from terminating the entire
PrintException command. When running with the cDAC in no-fallback mode,
some IXCLRDataProcess methods may AV instead of returning error codes.

Also add pointer validation in GetStackTraceArray to reject known-invalid
stack trace pointers (e.g. 0xFFFFFFFFFFFFFFFF) before dereferencing them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When running with the cDAC in no-fallback mode, the notification callback
chain (OnModuleLoaded, OnCodeGenerated, etc.) may encounter null pointers
in contract data, causing access violations. Wrap the call in SEH to
prevent the AV from terminating the SOSHandleCLRN command.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add SafeGetExceptionData and SafeFormatException SEH wrappers to protect
against access violations when the cDAC reads uninitialized exception
fields (e.g., _stackTrace containing 0xFFFFFFFFFFFFFFFF at exception
creation time). This prevents SOS from crashing in dotnet-dump when
running without legacy DAC fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When SafeFormatException catches an access violation from the cDAC,
the NativeAOT runtime may be left in a corrupted state. Previously,
PrintException would continue calling into the cDAC for nested
exception info (GetCurrentManagedThread, Thread.Request), causing
a cascading unhandled AV that crashed the entire debugger extension.

Now check SafeFormatException's return value and bail out early
if it failed, preventing the cascading crash.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant