Skip to content

IL Compiler crashes compiling abstract static methods #1665

Closed
@harryherold

Description

@harryherold

Enviroment

Architecture: x86-x64
DotNet Version: 6.0 using preview features
IL Compiler Version: 7.0.0-alpha.1.21518.2
Building on: Windows 10
Microsoft Visual Studio Community 2022 RC

Test case

Source Code:

public interface Animal
{
    static abstract bool eat(string food);
}
public class Mungo : Animal
{
    static public bool eat(string food)
    {
        return true;
    }
}
public class Duck : Animal
{
    static public bool eat(string food)
    {
        return true;
    }
}

Project file:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net6.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <LangVersion>preview</LangVersion>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="7.0.0-*" />
    </ItemGroup>
</Project>

Problem

The provided test case causes to crash the IL compiler and it is not enable to publish the binary.
Following stack trace is printed out:

3>Object reference not set to an instance of an object.
3>System.NullReferenceException: Object reference not set to an instance of an object.
3>   at ILCompiler.MethodExtensions.CanMethodBeInSealedVTable(MethodDesc method)
3>   at ILCompiler.DependencyAnalysis.SealedVTableNode.BuildSealedVTableSlots(NodeFactory factory, Boolean relocsOnly)
3>   at ILCompiler.DependencyAnalysis.EETypeNode.ComputeRareFlags(NodeFactory factory, Boolean relocsOnly)
3>   at ILCompiler.DependencyAnalysis.EETypeNode.ComputeOptionalEETypeFields(NodeFactory factory, Boolean relocsOnly)
3>   at ILCompiler.DependencyAnalysis.EETypeNode.GetData(NodeFactory factory, Boolean relocsOnly)
3>   at ILCompiler.DependencyAnalysis.ObjectNode.GetStaticDependencies(NodeFactory factory)
3>   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1 node)
3>   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependencies(DependencyNodeCore`1 node)
3>   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack()
3>   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes()
3>   at ILCompiler.RyuJitCompilation.CompileInternal(String outputFile, ObjectDumper dumper)
3>   at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String outputFile, ObjectDumper dumper)
3>   at ILCompiler.Program.Run(String[] args)
3>   at ILCompiler.Program.Main(String[] args)
3>The command ""C:\Users\cvonwascinski\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\7.0.0-alpha.1.21518.2\tools\ilc" @"obj\Release\net6.0\win-x64\native\ConsoleApp1.ilc.rsp"" exited with code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclr.NET runtime optimized for ahead of time compilation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions