KirillOsenkov/MetadataTools

BinaryCompatChecker stack overflow in Cecil custom resolver

KirillOsenkov opened this issue · 6 comments

000000d5`7ac26320 00007ff9`a6b71b81 mscorlib_ni!System.Globalization.TextInfo.GetCaseInsensitiveHashCode+0x41
000000d5`7ac26360 00007ff9`a6b71abf mscorlib_ni!System.OrdinalComparer.GetHashCode+0x2f
000000d5`7ac26390 00007ff9`a6b78ca0 mscorlib_ni!System.Collections.Generic.Dictionary_2[[System.__Canon,_mscorlib],[System.__Canon,_mscorlib]].FindEntry+0x60
000000d5`7ac26400 00007ff9`a6b784f4 mscorlib_ni!System.Collections.Generic.Dictionary_2[[System.__Canon,_mscorlib],[System.__Canon,_mscorlib]].TryGetValue+0x14
000000d5`7ac26440 00007ff9`4979e5b0 BinaryCompatChecker!BinaryCompatChecker.Checker.Resolve+0x90
000000d5`7ac26680 00007ff9`497b28de BinaryCompatChecker!BinaryCompatChecker.Checker+CustomAssemblyResolver.Resolve+0x4e
000000d5`7ac266f0 00007ff9`497b2860 UNKNOWN!Mono.Cecil.BaseAssemblyResolver.Resolve+0x60
000000d5`7ac26730 00007ff9`497b25f0 UNKNOWN!Mono.Cecil.MetadataResolver.Resolve+0x120
000000d5`7ac26840 00007ff9`497b6cae UNKNOWN!Mono.Cecil.ModuleDefinition.Resolve+0x4e
000000d5`7ac26880 00007ff9`497b8729 UNKNOWN!Mono.Cecil.ExportedType.Resolve+0x59
000000d5`7ac268e0 00007ff9`497b2aab UNKNOWN!Mono.Cecil.MetadataResolver.GetType+0x14b
000000d5`7ac26990 00007ff9`497b2639 UNKNOWN!Mono.Cecil.MetadataResolver.Resolve+0x169
000000d5`7ac26aa0 00007ff9`497b6cae UNKNOWN!Mono.Cecil.ModuleDefinition.Resolve+0x4e
000000d5`7ac26ae0 00007ff9`497b8729 UNKNOWN!Mono.Cecil.ExportedType.Resolve+0x59
 	Mono.Cecil.dll!Mono.Cecil.MetadataResolver.Resolve Line 114	C#
 	Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.Resolve Line 715	C#
 	Mono.Cecil.dll!Mono.Cecil.ExportedType.Resolve Line 230	C#
 	Mono.Cecil.dll!Mono.Cecil.MetadataResolver.GetType Line 150	C#
>	Mono.Cecil.dll!Mono.Cecil.MetadataResolver.Resolve Line 114	C#
 	Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.Resolve Line 715	C#
 	Mono.Cecil.dll!Mono.Cecil.ExportedType.Resolve Line 230	C#
 	Mono.Cecil.dll!Mono.Cecil.MetadataResolver.GetType Line 150	C#
 	Mono.Cecil.dll!Mono.Cecil.MetadataResolver.Resolve Line 114	C#

Inspecting Microsoft.Language.Xml.dll. Resolving method:

{System.Void System.Collections.Generic.Stack`1<Microsoft.Language.Xml.InternalSyntax.GreenNode>::.ctor()}

First it resolves {netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51} to {netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51}

Then it resolves {System.Collections, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a} to {System.Collections, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a}

Looks like I just hit this bug

  <!-- source code is at
  https://github.com/KirillOsenkov/MetadataTools/tree/main/src/BinaryCompatChecker
  -->
  <ItemGroup>
    <PackageReference Include="BinaryCompatChecker" Version="1.0.20" />
  </ItemGroup>
    at System.Collections.Generic.Dictionary`2<TKey_REF, TValue_REF>.TryGetValue (TKey_REF,TValue_REF&) [0x00000] in <36514b14425c4337b446653c547aa9c3>:0
    at BinaryCompatChecker.Checker.Resolve (Mono.Cecil.AssemblyNameReference) [0x0000f] in <b2206ab48c2c42669f70980865e7a2a7>:0
    at BinaryCompatChecker.Checker/CustomAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference,Mono.Cecil.ReaderParameters) [0x00007] in <b2206ab48c2c42669f70980865e7a2a7>:0
    at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference) [0x00007] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference) [0x0003a] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference) [0x00006] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.ExportedType.Resolve () [0x0000c] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.MetadataResolver.GetType (Mono.Cecil.ModuleDefinition,Mono.Cecil.TypeReference) [0x00050] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference) [0x00057] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference) [0x00006] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.ExportedType.Resolve () [0x0000c] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.MetadataResolver.GetType (Mono.Cecil.ModuleDefinition,Mono.Cecil.TypeReference) [0x00050] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference) [0x00057] in <2fc9a342bf2749daa85435ac40654aca>:0
    at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference) [0x00006] in <2fc9a342bf2749daa85435ac40654aca>:0

can you send me the .dmg link that hit this?

@KirillOsenkov This is it https://devdiv.visualstudio.com/_apis/resources/Containers/7562158/drop?itemPath=drop%2FVisualStudioForMac-8.10.0.1171-pre.3.dmg

I am in the process of converting the F# Interactive pad backend from a mono executable into a dotnet one. I have to ship the dotnet framework assemblies in the bundle as we can't assume that dotnet is already installed.

FWIW, I'm planning on side-stepping this issue completely as I don't believe that we need to run the Binary Compatibility checker on this executable as it is standalone.

Cool. Yes we should exclude standalone apps in BinaryCheckerConfig.txt.

But I’ll still investigate.