From aa8eb010d87274aa55e8e526fad53142cfbc734f Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 4 Jan 2023 12:17:39 -0800
Subject: [PATCH] Generate diagnosable failfast in GVM resolution (#78936)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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
```
Co-authored-by: Michal Strehovský
---
.../TypeLoaderEnvironment.GVMResolution.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.GVMResolution.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.GVMResolution.cs
index 99f7272b3ec9d7..7c411f987bd9d3 100644
--- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.GVMResolution.cs
+++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.GVMResolution.cs
@@ -72,13 +72,13 @@ public bool TryGetGenericVirtualTargetForTypeAndSlot(RuntimeTypeHandle targetHan
var sb = new System.Text.StringBuilder();
sb.AppendLine("Generic virtual method pointer lookup failure.");
sb.AppendLine();
- sb.AppendLine("Declaring type handle: " + declaringType.LowLevelToStringRawEETypeAddress());
- sb.AppendLine("Target type handle: " + targetHandle.LowLevelToStringRawEETypeAddress());
+ sb.AppendLine("Declaring type handle: " + RuntimeAugments.GetLastResortString(declaringType));
+ sb.AppendLine("Target type handle: " + RuntimeAugments.GetLastResortString(targetHandle));
sb.AppendLine("Method name: " + methodNameAndSignature.Name);
sb.AppendLine("Instantiation:");
for (int i = 0; i < genericArguments.Length; i++)
{
- sb.AppendLine(" Argument " + i.LowLevelToString() + ": " + genericArguments[i].LowLevelToStringRawEETypeAddress());
+ sb.AppendLine(" Argument " + i.LowLevelToString() + ": " + RuntimeAugments.GetLastResortString(genericArguments[i]));
}
Environment.FailFast(sb.ToString());
@@ -616,13 +616,13 @@ private unsafe bool ResolveGenericVirtualMethodTarget_Static(RuntimeTypeHandle t
var sb = new System.Text.StringBuilder();
sb.AppendLine("Generic virtual method pointer lookup failure.");
sb.AppendLine();
- sb.AppendLine("Declaring type handle: " + declaringType.LowLevelToStringRawEETypeAddress());
- sb.AppendLine("Target type handle: " + targetTypeHandle.LowLevelToStringRawEETypeAddress());
+ sb.AppendLine("Declaring type handle: " + RuntimeAugments.GetLastResortString(declaringType));
+ sb.AppendLine("Target type handle: " + RuntimeAugments.GetLastResortString(targetTypeHandle));
sb.AppendLine("Method name: " + targetMethodNameAndSignature.Name);
sb.AppendLine("Instantiation:");
for (int i = 0; i < genericArguments.Length; i++)
{
- sb.AppendLine(" Argument " + i.LowLevelToString() + ": " + genericArguments[i].LowLevelToStringRawEETypeAddress());
+ sb.AppendLine(" Argument " + i.LowLevelToString() + ": " + RuntimeAugments.GetLastResortString(genericArguments[i]));
}
Environment.FailFast(sb.ToString());