From: Fadi Hanna Date: Wed, 1 Jun 2016 20:05:45 +0000 (-0700) Subject: Fix for issue 5343: Assert Failure: !"Cannot take the address of an uninstantiated... X-Git-Tag: submit/tizen/20210909.063632~11030^2~10297 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85688cfdf685500fc5f4651823819c71c91a6ba4;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix for issue 5343: Assert Failure: !"Cannot take the address of an uninstantiated generic method." (dotnet/coreclr#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. Commit migrated from https://github.com/dotnet/coreclr/commit/c1cf38369531d9fb98a1b26166a1e48c0c8c808d --- diff --git a/src/coreclr/src/vm/comdelegate.cpp b/src/coreclr/src/vm/comdelegate.cpp index 57e2803..b6cab68 100644 --- a/src/coreclr/src/vm/comdelegate.cpp +++ b/src/coreclr/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; + } } } }