Skip to content

Commit c3d1d75

Browse files
Generate diagnosable failfast in GVM resolution (#78904)
If the program hits the conditions in #77070, generate a failfast message that makes it possible to create a workaround. Instead of: ``` Process terminated. Generic virtual method pointer lookup failure. Declaring type handle: MethodTable:0x00007FF66E8587B8 Target type handle: MethodTable:0x00007FF66E858810 Method name: Serialize Instantiation: Argument 00000000: MethodTable:0x00007FF66E85DA08 ``` Generate: ``` Process terminated. Generic virtual method pointer lookup failure. Declaring type handle: EETypeRva:0x005438B8(MemoryPackFormatter2`1[MemPackObject]) Target type handle: EETypeRva:0x00543910(MemoryPackableFormatter2`1[MemPackObject]) Method name: Serialize Instantiation: Argument 00000000: EETypeRva:0x00529B38(System.Buffers.ArrayBufferWriter`1[System.Byte]) ``` The workaround is then: ```xml <Directives> <Application> <Assembly Name="repro"> <Type Name="MemoryPackableFormatter2`1[[MemPackObject]]"> <Method Name="Serialize" Dynamic="Required All"> <GenericArgument Name="System.Buffers.ArrayBufferWriter`1[[System.Byte, mscorlib]],System.Memory" /> </Method> </Type> </Assembly> </Application> </Directives> ```
1 parent 97f51dc commit c3d1d75

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.GVMResolution.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ public bool TryGetGenericVirtualTargetForTypeAndSlot(RuntimeTypeHandle targetHan
7272
var sb = new System.Text.StringBuilder();
7373
sb.AppendLine("Generic virtual method pointer lookup failure.");
7474
sb.AppendLine();
75-
sb.AppendLine("Declaring type handle: " + declaringType.LowLevelToStringRawEETypeAddress());
76-
sb.AppendLine("Target type handle: " + targetHandle.LowLevelToStringRawEETypeAddress());
75+
sb.AppendLine("Declaring type handle: " + RuntimeAugments.GetLastResortString(declaringType));
76+
sb.AppendLine("Target type handle: " + RuntimeAugments.GetLastResortString(targetHandle));
7777
sb.AppendLine("Method name: " + methodNameAndSignature.Name);
7878
sb.AppendLine("Instantiation:");
7979
for (int i = 0; i < genericArguments.Length; i++)
8080
{
81-
sb.AppendLine(" Argument " + i.LowLevelToString() + ": " + genericArguments[i].LowLevelToStringRawEETypeAddress());
81+
sb.AppendLine(" Argument " + i.LowLevelToString() + ": " + RuntimeAugments.GetLastResortString(genericArguments[i]));
8282
}
8383

8484
Environment.FailFast(sb.ToString());
@@ -616,13 +616,13 @@ private unsafe bool ResolveGenericVirtualMethodTarget_Static(RuntimeTypeHandle t
616616
var sb = new System.Text.StringBuilder();
617617
sb.AppendLine("Generic virtual method pointer lookup failure.");
618618
sb.AppendLine();
619-
sb.AppendLine("Declaring type handle: " + declaringType.LowLevelToStringRawEETypeAddress());
620-
sb.AppendLine("Target type handle: " + targetTypeHandle.LowLevelToStringRawEETypeAddress());
619+
sb.AppendLine("Declaring type handle: " + RuntimeAugments.GetLastResortString(declaringType));
620+
sb.AppendLine("Target type handle: " + RuntimeAugments.GetLastResortString(targetTypeHandle));
621621
sb.AppendLine("Method name: " + targetMethodNameAndSignature.Name);
622622
sb.AppendLine("Instantiation:");
623623
for (int i = 0; i < genericArguments.Length; i++)
624624
{
625-
sb.AppendLine(" Argument " + i.LowLevelToString() + ": " + genericArguments[i].LowLevelToStringRawEETypeAddress());
625+
sb.AppendLine(" Argument " + i.LowLevelToString() + ": " + RuntimeAugments.GetLastResortString(genericArguments[i]));
626626
}
627627

628628
Environment.FailFast(sb.ToString());

0 commit comments

Comments
 (0)