runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Assert failure ... 'GetType() == TI_METHOD' in 'OddPower:Main():int'

Open richardlford opened this issue 10 years ago • 4 comments

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.

richardlford avatar Dec 18 '15 23:12 richardlford

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.

sivarv avatar Jan 09 '16 00:01 sivarv

@sejongoh - assigning this to you as you are fixing RTM bugs.

sivarv avatar May 04 '16 21:05 sivarv

Fixed with dotnet/coreclr#4999

sejongoh avatar May 17 '16 20:05 sejongoh

@sejongoh Please close if fixed.

RussKeldorph avatar May 17 '16 20:05 RussKeldorph