Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit cad5b83

Browse files
author
John Chen (CLR)
committed
Fix generic struct delegate in ReadyToRun (#3690)
Port commit 70aee6c from master branch to release/1.0.0-rc2 branch The following code pattern triggers a crash when compiled into Ready To Run: struct S<T> { public void M() { ... } } class C { } Then create a delegate using S<C>.M The cause of the crash is calling S<C>.M normally reaches a shared generic method S<__Canon>.M, but for delegate creation we need to use the actual S<C>.M. Ready To Run generated code that attempts to create delegate using S<__Canon>.M, which is not allowed.
1 parent f57caca commit cad5b83

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/vm/prestub.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,6 +2349,14 @@ PCODE DynamicHelperFixup(TransitionBlock * pTransitionBlock, TADDR * pCell, DWOR
23492349
fReliable = true;
23502350
case ENCODE_DELEGATE_CTOR:
23512351
pMD = ZapSig::DecodeMethod(pModule, pInfoModule, pBlob, &th);
2352+
if (pMD->RequiresInstArg())
2353+
{
2354+
pMD = MethodDesc::FindOrCreateAssociatedMethodDesc(pMD,
2355+
th.AsMethodTable(),
2356+
FALSE /* forceBoxedEntryPoint */,
2357+
pMD->GetMethodInstantiation(),
2358+
FALSE /* allowInstParam */);
2359+
}
23522360
pMD->EnsureActive();
23532361
break;
23542362
default:

0 commit comments

Comments
 (0)