Skip to content

Add support for async thunk methods in GetNativeCodeInfo#124354

Merged
tommcdon merged 5 commits intodotnet:mainfrom
tommcdon:dev/tommcdon/fix_dac_getnativecodeinfo
Mar 20, 2026
Merged

Add support for async thunk methods in GetNativeCodeInfo#124354
tommcdon merged 5 commits intodotnet:mainfrom
tommcdon:dev/tommcdon/fix_dac_getnativecodeinfo

Conversation

@tommcdon
Copy link
Member

@tommcdon tommcdon commented Feb 12, 2026

The runtime by default caches the async thunk when looking up runtime async methods in the methoddef map:

// For {Task-returning, Async} variants of the same definition
// we associate the methoddef with the Task-returning variant since it
// matches the methadata signature.
if (!pMD->IsUnboxingStub() && !pMD->IsAsyncVariantMethod())
{
pModule->EnsuredStoreMethodDef(pMD->GetMemberDef(), pMD);
}

This causes DacDbiInterfaceImpl::GetNativeCodeInfo to incorrectly return data for the async thunk and not the actual method.

@tommcdon tommcdon added this to the 11.0.0 milestone Feb 12, 2026
@tommcdon tommcdon self-assigned this Feb 12, 2026
Copilot AI review requested due to automatic review settings February 12, 2026 21:01
@dotnet-policy-service
Copy link
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
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

This PR attempts to fix an issue where DacDbiInterfaceImpl::GetNativeCodeInfo incorrectly returns data for async thunk methods instead of the actual async implementation method. The runtime caches async thunks in the methoddef map (see clsload.cpp:2804-2810), causing FindLoadedMethodRefOrDef to return the thunk. This PR adds logic to detect async thunk methods and attempts to find the corresponding async implementation method by iterating through all methods in the type.

Changes:

  • Added logic to detect async thunk methods using IsAsyncThunkMethod()
  • Implemented a loop to iterate through all introduced methods in the method table
  • Filters methods using IsDiagnosticsHidden() to find the actual async implementation method

@tommcdon
Copy link
Member Author

/ba-g changes only affect the DAC

Copilot AI review requested due to automatic review settings March 18, 2026 22:19
Copy link
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 6 out of 6 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: Noah Falk <noahfalk@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 19, 2026 16:19
Copy link
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 6 out of 6 changed files in this pull request and generated 1 comment.


You can also share your feedback on Copilot code review. Take the survey.

@tommcdon
Copy link
Member Author

/ba-g failures are known issues

@tommcdon tommcdon merged commit 83f84b6 into dotnet:main Mar 20, 2026
90 of 101 checks passed
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