Fix DAC AMD64 unwinder null deref on zero read address (#126081)#130527
Open
steveisok wants to merge 1 commit into
Open
Fix DAC AMD64 unwinder null deref on zero read address (#126081)#130527steveisok wants to merge 1 commit into
steveisok wants to merge 1 commit into
Conversation
The DAC's AMD64 stack unwinder reads target memory via MemoryRead64/128, which resolve to dac_cast<>::operator* -> DacInstantiateTypeByAddress. That helper's `preserve special pointer values'' fast-path returns a NULL host pointer for target addresses 0 and (TADDR)-1 *without* throwing, even though the read is invoked with throwEx == true. operator* then unconditionally dereferences the NULL, faulting inside the DAC itself (observed as 'segfault at 0 ... in libmscordaccore.so' on the DBI-Callback thread when an unwind step reads at ContextRecord->Rsp == 0). Honor the read's throw-on-failure contract in the DAC build by rejecting the 0 / (TADDR)-1 special addresses in MemoryRead64/128 so the stackwalk aborts cleanly with a DacError instead of crashing. This covers every unchecked read site in the amd64 unwinder at once and is scoped to DACCESS_COMPILE, leaving the online/JIT unwinder unchanged. 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
This PR hardens the CoreCLR AMD64 unwinder when built for DAC (out-of-process debugging) by turning otherwise-fatal reads from “special” target addresses (0 and (TADDR)-1) into a clean DAC error instead of a null-pointer dereference inside libmscordaccore.
Changes:
- Add a DAC-only guard in
MemoryRead64to reject read addresses0and(TADDR)-1and raiseDacError(HRESULT_FROM_WIN32(ERROR_READ_FAULT)). - Add the corresponding DAC-only guard in
MemoryRead128to prevent the same failure mode for 128-bit reads.
This was referenced Jul 11, 2026
Open
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.
The DAC's AMD64 stack unwinder reads target memory via MemoryRead64/128, which resolve to dac_cast<>::operator* -> DacInstantiateTypeByAddress. That helper's `preserve special pointer values'' fast-path returns a NULL host pointer for target addresses 0 and (TADDR)-1 without throwing, even though the read is invoked with throwEx == true. operator* then unconditionally dereferences the NULL, faulting inside the DAC itself (observed as 'segfault at 0 ... in libmscordaccore.so' on the DBI-Callback thread when an unwind step reads at ContextRecord->Rsp == 0).
Honor the read's throw-on-failure contract in the DAC build by rejecting the 0 / (TADDR)-1 special addresses in MemoryRead64/128 so the stackwalk aborts cleanly with a DacError instead of crashing. This covers every unchecked read site in the amd64 unwinder at once and is scoped to DACCESS_COMPILE, leaving the online/JIT unwinder unchanged.
Contributes to #126081