Skip to content

Commit

Permalink
Fix add/edit for generic methods scenario (#85655)
Browse files Browse the repository at this point in the history
Ensure the canonical MethodTable is always used.
  • Loading branch information
AaronRobinsonMSFT authored May 2, 2023
1 parent 2a216ab commit 34138a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/coreclr/vm/methoditer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BOOL LoadedMethodDescIterator::Next(
{
NOTHROW;
GC_NOTRIGGER;
MODE_PREEMPTIVE;
MODE_ANY;
}
CONTRACTL_END

Expand Down Expand Up @@ -203,15 +203,11 @@ MethodDesc *LoadedMethodDescIterator::Current()
return m_mainMD;
}

MethodTable *pMT = m_typeIteratorEntry->GetTypeHandle().GetMethodTable();
MethodTable *pMT = m_typeIteratorEntry->GetTypeHandle().GetMethodTable()->GetCanonicalMethodTable();
PREFIX_ASSUME(pMT != NULL);
_ASSERTE(pMT);

return pMT->GetMethodDescForSlot(m_mainMD->GetSlot());
return pMT->GetParallelMethodDesc(m_mainMD);
}

// Initialize the iterator. It will cover generics + prejitted;
// but it is not EnC aware.
void
LoadedMethodDescIterator::Start(
AppDomain * pAppDomain,
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8770,6 +8770,7 @@ namespace
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(pMT != NULL);
PRECONDITION(pMT->IsCanonicalMethodTable());
PRECONDITION(pDefMD != NULL);
PRECONDITION(pDefMD->IsEnCAddedMethod());
PRECONDITION(pDefMD->GetSlot() == MethodTable::NO_SLOT);
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/vm/runtimehandles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2413,7 +2413,8 @@ FCIMPL2(MethodDesc*, RuntimeMethodHandle::GetMethodFromCanonical, MethodDesc *pM
REFLECTCLASSBASEREF refType = (REFLECTCLASSBASEREF)ObjectToOBJECTREF(pTypeUNSAFE);

TypeHandle instType = refType->GetType();
MethodDesc* pMDescInCanonMT = instType.GetMethodTable()->GetParallelMethodDesc(pMethod);
MethodTable* pCanonMT = instType.GetMethodTable()->GetCanonicalMethodTable();
MethodDesc* pMDescInCanonMT = pCanonMT->GetParallelMethodDesc(pMethod);

return pMDescInCanonMT;
}
Expand Down

0 comments on commit 34138a1

Please sign in to comment.