dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.38k stars 4.75k forks source link

Assert in FrozenObjectNode.EncodeData #95852

Closed filipnavara closed 11 months ago

filipnavara commented 11 months ago

Steps to reproduce:

  1. Create new app with dotnet new webapiaot
  2. Run dotnet publish
  3. Run <path to runtime>/artifacts/bin/coreclr/linux.x64.Debug/ilc/ilc @./obj/Release/net8.0/linux-x64/native/webapiaot.ilc.rsp (ie. run a debug build of ILC from main)
Process terminated. Assertion failed.
   at ILCompiler.DependencyAnalysis.FrozenObjectNode.EncodeData(ObjectDataBuilder& dataBuilder, NodeFactory factory, Boolean relocsOnly) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenObjectNode.cs:line 43
   at ILCompiler.DependencyAnalysis.FrozenObjectNode.GetStaticDependencies(NodeFactory factory) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenObjectNode.cs:line 49
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1 node) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 182
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependencies(DependencyNodeCore`1 node) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 222
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 257
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 308
   at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 140
   at ILCompiler.Program.<Run>g__RunScanner|4_0(<>c__DisplayClass4_0&) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 474
   at ILCompiler.Program.Run() in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 454
   at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass221_0.<.ctor>b__0(ParseResult result) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs:line 277
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
   at System.CommandLine.ParseResult.Invoke()
   at ILCompiler.Program.Main(String[] args) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 737
ghost commented 11 months ago

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

Issue Details
Steps to reproduce: 1. Create new app with `dotnet new webapiaot` 2. Run `dotnet publish` 3. Run `/artifacts/bin/coreclr/linux.x64.Debug/ilc/ilc @./obj/Release/net8.0/linux-x64/native/webapiaot.ilc.rsp` (ie. run a debug build of ILC from main) ``` Process terminated. Assertion failed. at ILCompiler.DependencyAnalysis.FrozenObjectNode.EncodeData(ObjectDataBuilder& dataBuilder, NodeFactory factory, Boolean relocsOnly) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenObjectNode.cs:line 43 at ILCompiler.DependencyAnalysis.FrozenObjectNode.GetStaticDependencies(NodeFactory factory) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenObjectNode.cs:line 49 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1 node) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 182 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependencies(DependencyNodeCore`1 node) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 222 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 257 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 308 at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 140 at ILCompiler.Program.g__RunScanner|4_0(<>c__DisplayClass4_0&) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 474 at ILCompiler.Program.Run() in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 454 at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass221_0.<.ctor>b__0(ParseResult result) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs:line 277 at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult) at System.CommandLine.ParseResult.Invoke() at ILCompiler.Program.Main(String[] args) in /home/navara/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 737 ```
Author: filipnavara
Assignees: -
Labels: `os-linux`, `arch-x64`, `area-NativeAOT-coreclr`
Milestone: -
filipnavara commented 11 months ago
dataBuilder.CountBytes: 32
sizeBefore: 8
ContentSize: 8
Type name: ILCompiler.DependencyAnalysis.FrozenRuntimeTypeNode
filipnavara commented 11 months ago

Presumably this would fix it:

--- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenRuntimeTypeNode.cs
+++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenRuntimeTypeNode.cs
@@ -26,7 +26,7 @@ public override void AppendMangledName(NameMangler nameMangler, Utf8StringBuilde
             sb.Append(nameMangler.CompilationUnitPrefix).Append("__RuntimeType_").Append(nameMangler.GetMangledTypeName(_type));
         }

-        protected override int ContentSize => ObjectType.InstanceByteCount.AsInt;
+        protected override int ContentSize => 3 * _type.Context.Target.PointerSize;

         public override void EncodeContents(ref ObjectDataBuilder dataBuilder, NodeFactory factory, bool relocsOnly)
         {
MichalStrehovsky commented 11 months ago

You have a mismatched compiler and corelib. In .net 9 layout of RuntimeType was changed and compiler started emitting RuntimeType as a frozen object. We don't support targeting old corelib with new compiler. They must version together.

Use a .net 9 .net installer build

filipnavara commented 11 months ago

Thanks for explaining!