Add AsyncVariantLookup::ReturnDroppingThunk for parallel RDT lookup in FindOrCreateAssociatedMethodDesc#129442
Draft
Copilot wants to merge 3 commits into
Draft
Add AsyncVariantLookup::ReturnDroppingThunk for parallel RDT lookup in FindOrCreateAssociatedMethodDesc#129442Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Contributor
|
Tagging subscribers to this area: @agocke |
…reateAssociatedMethodDesc Co-authored-by: VSadov <8218165+VSadov@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix generic virtual method test for CoreCLR
Add AsyncVariantLookup::ReturnDroppingThunk for parallel RDT lookup in FindOrCreateAssociatedMethodDesc
Jun 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates CoreCLR’s async-variant method lookup so that ReturnDroppingThunk (RDT) methods can be distinguished from “regular” async variants during FindOrCreateAssociatedMethodDesc / instantiated-method-desc hashtable lookups, preventing incorrect matches when multiple async-kind variants share the same method identity apart from async kind.
Changes:
- Adds
AsyncVariantLookup::ReturnDroppingThunkplusMethodDesc::GetAsyncVariantLookup()and updates matching logic (MatchesAsyncVariantLookup) to disambiguate regular async variants vs RDTs. - Widens instantiated-method-desc lookup APIs from
bool isAsyncVarianttoAsyncVariantLookupand updates call sites accordingly. - Modifies the covariant-return async test by removing an
ActiveIssueskip annotation onTestGenericVirtualMethod.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/async/covariant-return/covariant-returns.cs | Removes the ActiveIssue gate for TestGenericVirtualMethod, re-enabling the test. |
| src/coreclr/vm/method.hpp | Introduces AsyncVariantLookup::ReturnDroppingThunk, adds GetAsyncVariantLookup(), and refines async-kind matching logic. |
| src/coreclr/vm/instmethhash.h | Updates InstMethodHashTable::FindMethodDesc signature to accept AsyncVariantLookup (and adds a forward declaration). |
| src/coreclr/vm/instmethhash.cpp | Uses MatchesAsyncVariantLookup + GetAsyncVariantLookup() to filter and validate hashtable entries. |
| src/coreclr/vm/genmeth.cpp | Plumbs AsyncVariantLookup through instantiated method desc lookups/creation paths. |
Comment on lines
226
to
227
| [Fact] | ||
| [ActiveIssue("https://github.com/dotnet/runtime/issues/127197", typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.IsNotNativeAot))] | ||
| public static void TestGenericVirtualMethod() |
Comment on lines
1729
to
+1732
| // by default async lookup matches the primaryMD | ||
| AsyncVariantLookup variantLookup = pPrimaryMD->IsAsyncVariantMethod() ? AsyncVariantLookup::Async : AsyncVariantLookup::Ordinary; | ||
| AsyncVariantLookup variantLookup = pPrimaryMD->IsReturnDroppingThunk() ? AsyncVariantLookup::ReturnDroppingThunk : | ||
| pPrimaryMD->IsAsyncVariantMethod() ? AsyncVariantLookup::Async : | ||
| AsyncVariantLookup::Ordinary; |
Comment on lines
19
to
21
| class AllocMemTracker; | ||
| enum class AsyncVariantLookup : int; | ||
|
|
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 assert
!pPrimaryMD->IsReturnDroppingThunk()inFindOrCreateAssociatedMethodDescfires for generic virtual methods with covariant return, when the primaryMethodDescis itself aReturnDroppingThunk(RDT) and we need to look up a parallel RDT that differs only in something other than async kind (e.g. generic arguments). The instantiated-method-desc hash table also keyed on a singlebool isAsyncVariant, which cannot distinguish a regular async variant from an RDT (both haveIsAsyncVariantMethod() == true).Changes
AsyncVariantLookup::ReturnDroppingThunkenum value (method.hpp) — matched only by methods whereIsReturnDroppingThunk()is true. ExistingAsynccontinues to match only regular async variants (not RDTs).MethodDesc::GetAsyncVariantLookup()helper — returns the lookup value matching a method's own async kind (Ordinary/Async/ReturnDroppingThunk).Convenience overload of
FindOrCreateAssociatedMethodDesc— replaces the_ASSERTE(!pPrimaryMD->IsReturnDroppingThunk())with a 3-way selection of the variant lookup based on the primary MD:AsyncVariantLookup variantLookup = pPrimaryMD->IsReturnDroppingThunk() ? AsyncVariantLookup::ReturnDroppingThunk : pPrimaryMD->IsAsyncVariantMethod() ? AsyncVariantLookup::Async : AsyncVariantLookup::Ordinary;Hash table API widened —
InstMethodHashTable::FindMethodDescandInstantiatedMethodDesc::FindLoadedInstantiatedMethodDescnow takeAsyncVariantLookupinstead ofbool isAsyncVariant;ContainsMethodDescpassespMD->GetAsyncVariantLookup(). All 9 call sites ingenmeth.cppupdated. This is required because aboolkey cannot disambiguate regular-async from RDT entries that hash to the same bucket — without it,GetAsyncVariant()on an RDT can return the RDT itself.Notes
GetAsyncVariant()on an RDT now correctly returns its parallel regular-async variant.TestGenericVirtualMethodon CoreCLR surfaces a separate, deeper bug in shared-canonical GVM dispatch (recursive re-entry into the RDT, stack overflow). That is out of scope for this change set, so the existing[ActiveIssue(...)]attribute on the test is intentionally left in place. The enum/lookup changes here are self-contained prerequisites that remove the misleading assert and unblock further investigation.Note
This PR description and the changes were generated with assistance from GitHub Copilot.