Skip to content

NativeAOT compiler crashes if assembly missing #70815

Description

@kant2002

Create console application which targets net7.0 and attempt to add Microsoft.Extensions.Hosting with explicit dependencies and missing reference to Microsoft.Extensions.Configuration.EnvironmentVariables. ILC crashes.

  System.AggregateException: One or more errors occurred. (Code generation failed for method '[Microsoft.Extensions.Hosting]Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.ConfigureDefaults(IHostBui
  lder,string[])')
   ---> ILCompiler.CodeGenerationFailedException: Code generation failed for method '[Microsoft.Extensions.Hosting]Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.ConfigureDefaults(IHostBuilder,stri
  ng[])'
   ---> System.NullReferenceException: Object reference not set to an instance of an object.
     at ILCompiler.LazyGenericsSupport.GraphBuilder.WalkMethod(EcmaMethod method) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.cs:line 204
     at ILCompiler.LazyGenericsSupport.GraphBuilder..ctor(EcmaModule assembly) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.cs:line 59
     at ILCompiler.LazyGenericsSupport.CycleInfoHashtable.CreateValueFromKey(EcmaModule key) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/ModuleCycleInfo.cs:line 50
     at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey key) in /_/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs:line 559
     at ILCompiler.LazyGenericsSupport.GenericCycleDetector.DetectCycle(TypeSystemEntity owner, TypeSystemEntity referent) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/ModuleCycleInfo
  .cs:line 193
     at Internal.IL.ILImporter.GetMethodEntrypoint(MethodDesc method) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs:line 253
     at Internal.IL.ILImporter.ImportCall(ILOpcode opcode, Int32 token) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs:line 685
     at Internal.IL.ILImporter.ImportBasicBlock(BasicBlock basicBlock) in /_/src/coreclr/tools/Common/TypeSystem/IL/ILImporter.cs:line 600
     at Internal.IL.ILImporter.ImportBasicBlocks() in /_/src/coreclr/tools/Common/TypeSystem/IL/ILImporter.cs:line 311
     at Internal.IL.ILImporter.Import() in /_/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs:line 156
     at ILCompiler.ILScanner.CompileSingleMethod(ScannedMethodNode methodCodeNodeNeedingCode) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 123
     --- End of inner exception stack trace ---
     at ILCompiler.ILScanner.CompileSingleMethod(ScannedMethodNode methodCodeNodeNeedingCode) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 134
     at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
  --- End of stack trace from previous location ---
     at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
     at System.Threading.Tasks.TaskReplicator.Replica.Execute()
     --- End of inner exception stack trace ---
     at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
     at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit
  , Action`1 localFinally)
  --- End of stack trace from previous location ---
     at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit
  , Action`1 localFinally)
     at ILCompiler.ILScanner.CompileMultiThreaded(List`1 methodsToCompile) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 97
     at ILCompiler.ILScanner.ComputeDependencyNodeDependencies(List`1 obj) in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 86
     at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in /_/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 315
     at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() in /_/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 140
     at ILCompiler.Program.Run(String[] args) in /_/src/coreclr/tools/aot/ILCompiler/Program.cs:line 828
     at ILCompiler.Program.Main(String[] args) in /_/src/coreclr/tools/aot/ILCompiler/Program.cs:line 1085

Addition to console app.

<ItemGroup>
    <Reference Include="Microsoft.Extensions.Hosting">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.Hosting\Release\net7.0\Microsoft.Extensions.Hosting.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Extensions.Hosting.Abstractions">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.Hosting.Abstractions\Release\net7.0\Microsoft.Extensions.Hosting.Abstractions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Extensions.Logging">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.Logging\Release\net7.0\Microsoft.Extensions.Logging.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Extensions.Logging.Abstractions">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.Logging.Abstractions\Release\net7.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Extensions.DependencyInjection">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.DependencyInjection\Release\net7.0\Microsoft.Extensions.DependencyInjection.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.DependencyInjection.Abstractions\Release\net7.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Extensions.Configuration">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.Configuration\Release\net7.0\Microsoft.Extensions.Configuration.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Extensions.Configuration.Abstractions">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.Configuration.Abstractions\Release\net7.0\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Extensions.FileProviders.Physical">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.FileProviders.Physical\Release\net7.0\Microsoft.Extensions.FileProviders.Physical.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Extensions.FileProviders.Abstractions">
      <HintPath>$(RuntimeRepoRoot)artifacts\bin\Microsoft.Extensions.FileProviders.Abstractions\Release\net7.0\Microsoft.Extensions.FileProviders.Abstractions.dll</HintPath>
    </Reference>
  </ItemGroup>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions