Skip to content

Fix Array::GetDirectPointerToNonObjectElements DAC regression - #129271

Merged
tommcdon merged 2 commits into
dotnet:mainfrom
tommcdon:dev/tommcdon/fix-array-dac-regression
Jun 12, 2026
Merged

Fix Array::GetDirectPointerToNonObjectElements DAC regression#129271
tommcdon merged 2 commits into
dotnet:mainfrom
tommcdon:dev/tommcdon/fix-array-dac-regression

Conversation

@tommcdon

Copy link
Copy Markdown
Member

In DAC mode, m_Array yields a host address, but PTR_KIND requires a target address. GetDataPtr() computes the correct target address via dac_cast<PTR_BYTE>(this) + offset.

This was broken by PR #128961 which changed from GetDataPtr() to m_Array, breaking debugger inspection of exception stack traces, ConditionalWeakTable lookups, and stack frame helper arrays in DAC mode.

In DAC mode, m_Array yields a host address, but PTR_KIND requires a
target address. GetDataPtr() computes the correct target address via
dac_cast<PTR_BYTE>(this) + offset.

This was broken by PR dotnet#128961 which changed from GetDataPtr() to
m_Array, breaking debugger inspection of exception stack traces,
ConditionalWeakTable lookups, and stack frame helper arrays in DAC mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tommcdon tommcdon added this to the 11.0.0 milestone Jun 11, 2026
@tommcdon tommcdon self-assigned this Jun 11, 2026
Copilot AI review requested due to automatic review settings June 11, 2026 02:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a DAC (data access / debugger) regression in CoreCLR’s Array<KIND>::GetDirectPointerToNonObjectElements() by ensuring it returns a target address (as required by DPTR/PTR_KIND) rather than a host address derived from the m_Array field.

Changes:

  • Update Array<KIND>::GetDirectPointerToNonObjectElements() to return PTR_KIND(GetDataPtr()) instead of PTR_KIND(m_Array) so DAC computes the correct target address for array data.
  • Restore behavior compatible with DAC-based inspection scenarios that rely on correct primitive-array data pointers.
Comment thread src/coreclr/vm/object.h
Comment thread src/coreclr/vm/object.h Outdated
Comment thread src/coreclr/vm/object.h Outdated
Use dac_cast<PTR_KIND>(PTR_HOST_MEMBER_TADDR(Array, this, m_Array))
instead of PTR_KIND(GetDataPtr()) to correctly compute the target
address in DAC builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@tommcdon
tommcdon merged commit 23e9326 into dotnet:main Jun 12, 2026
111 of 113 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview6 Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
In DAC mode, m_Array yields a host address, but PTR_KIND requires a
target address. GetDataPtr() computes the correct target address via
dac_cast<PTR_BYTE>(this) + offset.

This was broken by PR #128961 which changed from GetDataPtr() to
m_Array, breaking debugger inspection of exception stack traces,
ConditionalWeakTable lookups, and stack frame helper arrays in DAC mode.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.