Skip to content

Fix x86 async frame generic type resolution in DBI#126915

Open
tommcdon wants to merge 2 commits intodotnet:mainfrom
tommcdon:dev/tommcdon/fix_x86_async_frame_generic_type_resolution
Open

Fix x86 async frame generic type resolution in DBI#126915
tommcdon wants to merge 2 commits intodotnet:mainfrom
tommcdon:dev/tommcdon/fix_x86_async_frame_generic_type_resolution

Conversation

@tommcdon
Copy link
Copy Markdown
Member

CordbAsyncFrame::LoadGenericArgs was using SafeReadStruct<CORDB_ADDRESS> to read the generic arg token from the continuation object. CORDB_ADDRESS is ULONG64 (always 8 bytes), but on x86 targets the field is a 4-byte pointer. Reading 8 bytes pulled in adjacent memory, producing garbage pointer values that caused EnumerateTypeParameters to return E_INVALIDARG.

Changed to SafeReadStruct<SIZE_T> which matches the target pointer size (4 bytes on x86, 8 bytes on x64), consistent with how CordbJITILFrame::LoadGenericArgs reads tokens via GetRegisterOrStackValue.

CordbAsyncFrame::LoadGenericArgs was using SafeReadStruct<CORDB_ADDRESS>
to read the generic arg token from the continuation object. CORDB_ADDRESS
is ULONG64 (always 8 bytes), but on x86 targets the field is a 4-byte
pointer. Reading 8 bytes pulled in adjacent memory, producing garbage
pointer values that caused EnumerateTypeParameters to return E_INVALIDARG.

Changed to SafeReadStruct<SIZE_T> which matches the target pointer size
(4 bytes on x86, 8 bytes on x64), consistent with how
CordbJITILFrame::LoadGenericArgs reads tokens via GetRegisterOrStackValue.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect generic type argument token reads for x86 async frames in the CoreCLR DBI by reading a pointer-sized value from the continuation object instead of an always-8-byte CORDB_ADDRESS, preventing adjacent-memory contamination and downstream E_INVALIDARG failures.

Changes:

  • Update CordbAsyncFrame::LoadGenericArgs to read the raw generic token as SIZE_T and then widen to CORDB_ADDRESS.
  • Add explanatory comments aligning the logic with the existing “read raw token then resolve via DAC” pattern used elsewhere.

@tommcdon
Copy link
Copy Markdown
Member Author

/ba-g test failures are unrelated

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 15, 2026 15:47
@tommcdon tommcdon enabled auto-merge (squash) April 15, 2026 15:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants