From c1cf38369531d9fb98a1b26166a1e48c0c8c808d Mon Sep 17 00:00:00 2001 From: Fadi Hanna Date: Wed, 1 Jun 2016 13:05:45 -0700 Subject: [PATCH] Fix for issue 5343: Assert Failure: !"Cannot take the address of an uninstantiated generic method." (#5347) The problem was that the delegates code base was not correctly instantiating interface GVMs on target types (after finding the target method on the target type using slot numbers), and ended up calling uninstantiated generic method definitions on delegate invokes. --- src/vm/comdelegate.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/vm/comdelegate.cpp b/src/vm/comdelegate.cpp index 57e2803..b6cab68 100644 --- a/src/vm/comdelegate.cpp +++ b/src/vm/comdelegate.cpp @@ -2102,11 +2102,25 @@ FCIMPL3(void, COMDelegate::DelegateConstruct, Object* refThisUNSAFE, Object* tar // it looks like we need to pass an ownerType in here. // Why can we take a delegate to an interface method anyway? // - pMeth = pMTTarg->FindDispatchSlotForInterfaceMD(pMeth).GetMethodDesc(); - if (pMeth == NULL) + MethodDesc * pDispatchSlotMD = pMTTarg->FindDispatchSlotForInterfaceMD(pMeth).GetMethodDesc(); + if (pDispatchSlotMD == NULL) { COMPlusThrow(kArgumentException, W("Arg_DlgtTargMeth")); } + + if (pMeth->HasMethodInstantiation()) + { + pMeth = MethodDesc::FindOrCreateAssociatedMethodDesc( + pDispatchSlotMD, + pDispatchSlotMD->GetMethodTable(), + (!pDispatchSlotMD->IsStatic() && pDispatchSlotMD->GetMethodTable()->IsValueType()), + pMeth->GetMethodInstantiation(), + FALSE /* allowInstParam */); + } + else + { + pMeth = pDispatchSlotMD; + } } } } -- 2.7.4