[cDAC] Fix NonVirtualEntry2MethodDesc to handle invalid precode addresses#124986
Merged
max-charlamb merged 2 commits intodotnet:mainfrom Mar 2, 2026
Merged
Conversation
…sses NonVirtualEntry2MethodDesc throws InvalidOperationException when an address falls in a precode RangeSection but doesn't match any known precode type. The DAC's C++ implementation returns NULL in this case. This mismatch caused a DEBUG assertion crash in GetCodeHeaderData (cDAC returned 0x80131509, DAC returned 0x80070057), breaking SOS !clru on IL stubs in the cDAC_windows_x64_release CI job. The fix catches InvalidOperationException from GetMethodDescFromStubAddress and returns TargetPointer.Null, matching the DAC behavior. Adds a dump test that exercises GetCodeHeaderData with an invalid precode address derived from the VarargPInvoke debuggee's entry point. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns cDAC behavior with the native DAC when given an address that falls within a precode RangeSection but does not correspond to a valid precode, preventing exceptions and downstream assertion failures.
Changes:
- Added a regression dump test that calls
GetCodeHeaderDatawith an intentionally invalid precode address and assertsE_INVALIDARG. - Updated
NonVirtualEntry2MethodDescto returnTargetPointer.Null(instead of throwing) when precode bytes are invalid.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/native/managed/cdac/tests/DumpTests/VarargPInvokeDumpTests.cs | Adds a regression test for invalid precode addresses passed to GetCodeHeaderData. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/ExecutionManager/ExecutionManagerCore.cs | Matches native DAC behavior by catching invalid-precode exceptions and returning Null. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
hoyosjs
approved these changes
Mar 2, 2026
Member
Author
|
/ba-g cDAC only change, runtime-diagnostics pipeline is 🟢 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
NonVirtualEntry2MethodDescthrowsInvalidOperationExceptionwhen an address falls in a precodeRangeSectionbut doesn't match any known precode type (e.g., a MethodDesc address that coincidentally shares the same memory range). The DAC's C++ implementation returnsNULLin this case.This mismatch caused a DEBUG assertion crash in
GetCodeHeaderData— the cDAC returned0x80131509(COR_E_INVALIDOPERATION) while the DAC returned0x80070057(E_INVALIDARG), triggeringDebug.Assert(hrLocal == hr)and crashing the process. This broke!clruon IL stubs in thecDAC_windows_x64_releaseCI job (build 1313397).Fix
Catch
InvalidOperationExceptionfromGetMethodDescFromStubAddressinExecutionManagerCore.NonVirtualEntry2MethodDescand returnTargetPointer.Null, matching the DAC's C++ behavior whereNonVirtualEntry2MethodDescreturnsNULLfor unrecognized addresses.Test
Adds
VarargPInvoke_GetCodeHeaderDataWithInvalidPrecodeAddressdump test that:GetCodeHeaderData(SOS-level API) and asserts it returnsE_INVALIDARGVerified the test fails without the fix (returns
COR_E_INVALIDOPERATION) and passes with the fix (returnsE_INVALIDARG).