Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

F# TestSuite: refnormalization build fails with EXEC : error : VTable of type 'ArrayEnumerator<System.Reflection.AssemblyName>' not computed by the IL scanner. #5827

Open
zpodlovics opened this issue May 21, 2018 · 1 comment
Milestone

Comments

@zpodlovics
Copy link

I have modified the refnormalization test [1] for F# testsuite and tried to compile it with CoreRT.

Example project:
refnormalization.zip

The ILCompiler fails with the following message:

dotnet publish -c Release -r linux-x64 /p:CORERT=true
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for /tmp/refnormalization/test.fsproj...
  Generating MSBuild file /tmp/refnormalization/obj/test.fsproj.nuget.g.props.
  Generating MSBuild file /tmp/refnormalization/obj/test.fsproj.nuget.g.targets.
  Restore completed in 1.53 sec for /tmp/refnormalization/test.fsproj.
  test -> /tmp/refnormalization/bin/Release/netcoreapp2.0/linux-x64/test.dll
  /usr/bin/clang-3.9
  Generating native code
EXEC : error : VTable of type 'ArrayEnumerator<System.Reflection.AssemblyName>' not computed by the IL scanner. You can work around by running the compilation with scanner disabled. [/tmp/refnormalization/test.fsproj]
  ILCompiler.ScannerFailedException: VTable of type 'ArrayEnumerator<System.Reflection.AssemblyName>' not computed by the IL scanner. You can work around by running the compilation with scanner disabled.
     at ILCompiler.ILScanResults.ScannedVTableProvider.GetSlice(TypeDesc type)
     at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
     at ILCompiler.DependencyAnalysis.EETypeNode.AddVirtualMethodUseDependencies(DependencyList dependencyList, NodeFactory factory)
     at ILCompiler.DependencyAnalysis.EETypeNode.ComputeNonRelocationBasedDependencies(NodeFactory factory)
     at ILCompiler.DependencyAnalysis.ConstructedEETypeNode.ComputeNonRelocationBasedDependencies(NodeFactory factory)
     at ILCompiler.DependencyAnalysis.ObjectNode.GetStaticDependencies(NodeFactory factory)
     at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1 node)
     at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack()
     at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes()
     at ILCompiler.RyuJitCompilation.CompileInternal(String outputFile, ObjectDumper dumper)
     at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String outputFile, ObjectDumper dumper)
     at ILCompiler.Program.Run(String[] args)
     at ILCompiler.Program.Main(String[] args)
/home/zpodlovics/.nuget/packages/microsoft.dotnet.ilcompiler/1.0.0-alpha-26519-01/build/Microsoft.NETCore.Native.targets(183,5): error MSB3073: The command ""/home/zpodlovics/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/1.0.0-alpha-26519-01/tools/ilc" @"obj/Release/netcoreapp2.0/linux-x64/native/test.ilc.rsp"" exited with code 1. [/tmp/refnormalization/test.fsproj]

Steps to reproduce:

cd /tmp
unzip path/to/refnormalization.zip
cd refnormalization
dotnet publish -c Release -r linux-x64 /p:CORERT=true

[1] https://github.com/Microsoft/visualfsharp/tree/master/tests/fsharp/core/refnormalization

@zpodlovics zpodlovics changed the title F# TestSuite: refnormalization build fails with EXEC : error : VTable of type 'ArrayEnumerator<System.Reflection.AssemblyName>' not computed by the IL scanner. You can work around by running the compilation with scanner disabled. [/tmp/refnormalization/test.fsproj] F# TestSuite: refnormalization build fails with EXEC : error : VTable of type 'ArrayEnumerator<System.Reflection.AssemblyName>' not computed by the IL scanner. May 21, 2018
@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented May 21, 2018

Nice bug. This can also be reproed with C#:

using System;
using System.Collections.Generic;

class Base
{
}

class Derived : Base
{
}

internal class Program
{
    private readonly Base[] _b = new Derived[1];

    private static void Main(string[] args)
    {
        IEnumerator<Base> e = ((IEnumerable<Base>)new Program()._b).GetEnumerator();
        while (e.MoveNext())
        {
            Console.WriteLine(e.Current);
        }
    }
}

It's an interaction with RyuJIT devirtualization and array covariance - RyuJIT devirtualizes the call to IEnumerable<Base> into a call to Array<Base> and bad things fall out of that because there never was an instance of Base[] seen anywhere in the scanning phase. I'll need to think about this a bit.

For now, passing -c Debug instead of -c Release should work around.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants