Assert failure ... 'GetType() == TI_METHOD' in 'OddPower:Main():int'
The following tests had this failure:
Assert failure ... 'GetType() == TI_METHOD' in 'OddPower:Main():int' (IL size 666)
- JIT\Methodical\delegate_simpleoddpower_il_d_simpleoddpower_il_d.cmd
- JIT\Methodical\delegate_simpleoddpower_il_r_simpleoddpower_il_r.cmd
on debug win64.
Short Summary: It is a benign assert due to a bit-rotten code transparency check in importer. Moving this to RTM.
Details:
Delegate creation pattern that is causing the assert failure: ldloc.0 dup call instance method int32 *() OddPower::GetMthdPtr1() newobj instance void OddPower/MyDeleg2::.ctor(object, native int)
Note that the delegate method funcptr is a pointer returned by GetMthPtr1(), which happens to be CORINFO_POINTER and an arbitrary pointer and not known to be a method ptr. During Delegate creation (using newobj), impImportImporter() has additional code that comes into effect only for CoreCLR that meant for code transparency.
#ifdef FEATURE_CORECLR
// In coreclr the delegate transparency rule needs to be enforced even if verification is disabled
typeInfo tiActualFtn = impStackTop(0).seTypeInfo;
CORINFO_METHOD_HANDLE delegateMethodHandle = tiActualFtn.GetMethod();
impInsertCalloutForDelegate(info.compMethodHnd,
delegateMethodHandle,
resolvedToken.hClass);
#endif // FEATURE_CORECLR
fiActualFtn.GetMethod() is asserting that the typinfo is TI_METHOD and in this case it is not.
Fix1: Use GetMethod2() that doesn't assert. Fix2: Clean up bit-rotten transparency code.
@sejongoh - assigning this to you as you are fixing RTM bugs.
Fixed with dotnet/coreclr#4999
@sejongoh Please close if fixed.