Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ilc compilation failure: Invalid IL or CLR metadata #99047

Closed
hez2010 opened this issue Feb 28, 2024 · 5 comments · Fixed by #99101
Closed

ilc compilation failure: Invalid IL or CLR metadata #99047

hez2010 opened this issue Feb 28, 2024 · 5 comments · Fixed by #99101

Comments

@hez2010
Copy link
Contributor

hez2010 commented Feb 28, 2024

Description

I'm experimenting with my profile guided aot runtime directives assistant against an asp.net core + efcore app, and managed to produce a rd.xml for it.
But when I build it with NativeAOT, it failed with Invalid IL or CLR metadata on [Microsoft.AspNetCore.Identity.EntityFrameworkCore]Microsoft.Extensions.DependencyInjection.IdentityEntityFrameworkBuilderExtensions.AddStores(IServiceCollection,Type,Type,Type)

Reproduction Steps

Repro:
WebSample.zip

Expected behavior

No compilation failure.

Actual behavior

ILC: Compiling [Microsoft.AspNetCore.Identity.EntityFrameworkCore]Microsoft.Extensions.DependencyInjection.IdentityEntityFrameworkBuilderExtensions.AddStores(IServiceCollection,Type,Type,Type)...
EXEC : error : Invalid IL or CLR metadata [D:\source\repos\Test\WebSample\WebSample.csproj]
  Internal.TypeSystem.TypeSystemException+InvalidProgramException: Invalid IL or CLR metadata
     at Internal.TypeSystem.ThrowHelper.ThrowInvalidProgramException() + 0x24
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode, MethodIL) + 0x22a
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode, MethodIL) + 0x5c
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl, MethodCodeNode) + 0xc7
     at ILCompiler.RyuJitCompilation.CompileSingleThreaded(List`1) + 0x24e
     at ILCompiler.RyuJitCompilation.ComputeDependencyNodeDependencies(List`1 obj) + 0x149
     at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() + 0x95
     at ILCompiler.RyuJitCompilation.CompileInternal(String, ObjectDumper) + 0x1f
     at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String, ObjectDumper) + 0x2d
     at ILCompiler.Program.Run() + 0x2772
     at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass227_0.<.ctor>b__0(ParseResult result) + 0x315

Regression?

No response

Known Workarounds

No response

Configuration

.NET 8.0.200

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Feb 28, 2024
@ghost
Copy link

ghost commented Feb 28, 2024

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

I'm experimenting with my profile guided aot runtime directives assistant against an asp.net core + efcore app, and managed to produce a rd.xml for it.
But when I build it with NativeAOT, it failed with Invalid IL or CLR metadata on [Microsoft.AspNetCore.Identity.EntityFrameworkCore]Microsoft.Extensions.DependencyInjection.IdentityEntityFrameworkBuilderExtensions.AddStores(IServiceCollection,Type,Type,Type)

Reproduction Steps

Repro:
WebSample.zip

Expected behavior

No compilation failure.

Actual behavior

ILC: Compiling [Microsoft.AspNetCore.Identity.EntityFrameworkCore]Microsoft.Extensions.DependencyInjection.IdentityEntityFrameworkBuilderExtensions.AddStores(IServiceCollection,Type,Type,Type)...
EXEC : error : Invalid IL or CLR metadata [D:\source\repos\Test\WebSample\WebSample.csproj]
  Internal.TypeSystem.TypeSystemException+InvalidProgramException: Invalid IL or CLR metadata
     at Internal.TypeSystem.ThrowHelper.ThrowInvalidProgramException() + 0x24
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode, MethodIL) + 0x22a
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode, MethodIL) + 0x5c
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl, MethodCodeNode) + 0xc7
     at ILCompiler.RyuJitCompilation.CompileSingleThreaded(List`1) + 0x24e
     at ILCompiler.RyuJitCompilation.ComputeDependencyNodeDependencies(List`1 obj) + 0x149
     at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() + 0x95
     at ILCompiler.RyuJitCompilation.CompileInternal(String, ObjectDumper) + 0x1f
     at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String, ObjectDumper) + 0x2d
     at ILCompiler.Program.Run() + 0x2772
     at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass227_0.<.ctor>b__0(ParseResult result) + 0x315

Regression?

No response

Known Workarounds

No response

Configuration

.NET 8.0.200

Other information

No response

Author: hez2010
Assignees: -
Labels:

untriaged, area-NativeAOT-coreclr

Milestone: -

@jkotas
Copy link
Member

jkotas commented Feb 28, 2024

rdxml is unsupported: https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/rd-xml-format.md . We plan to delete the support eventually.

This error means that your rdxml is malformed. We know that the experience for diagnosing wrong rdxml is bad. We do not plan to improve it.

profile guided aot runtime directives assistant

You may want to consider providing this information to the AOT compiler via additional C# source or IL assembly that has dynamically unreachable method with additional roots.

@jkotas jkotas added the question Answer questions and provide assistance, not an issue with source code or documentation. label Feb 28, 2024
@hez2010
Copy link
Contributor Author

hez2010 commented Feb 29, 2024

This error means that your rdxml is malformed.

It seems that the types in rdxml were rooted correctly, but failed at codegen for Microsoft.Extensions.DependencyInjection.IdentityEntityFrameworkBuilderExtensions.AddStores(IServiceCollection,Type,Type,Type): https://github.com/dotnet/aspnetcore/blob/3e168fe85e2330621ed12d9c9524c80e0f743dc6/src/Identity/EntityFrameworkCore/src/IdentityEntityFrameworkBuilderExtensions.cs#L29

jkotas added a commit to jkotas/runtime that referenced this issue Feb 29, 2024
@jkotas
Copy link
Member

jkotas commented Feb 29, 2024

rdxml is not required to reproduce this. It is enough to just call the AddStores method in the specific EF core version.

@jkotas jkotas removed the question Answer questions and provide assistance, not an issue with source code or documentation. label Feb 29, 2024
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 29, 2024
jkotas added a commit that referenced this issue Feb 29, 2024
@ghost ghost removed in-pr There is an active PR which will close this issue when it is merged untriaged New issue has not been triaged by the area owner labels Feb 29, 2024
@jkotas
Copy link
Member

jkotas commented Feb 29, 2024

Thank you for reporting this!

@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants