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

NativeAOT: Asking for Array<T> MethodTable #88287

Closed
filipnavara opened this issue Jul 1, 2023 · 5 comments
Closed

NativeAOT: Asking for Array<T> MethodTable #88287

filipnavara opened this issue Jul 1, 2023 · 5 comments

Comments

@filipnavara
Copy link
Member

Repro: https://1drv.ms/u/s!AgaMhbe7wFq8m8MQC0XPpTlHpadgrg?e=uS9Aqw

I was trying to debug why compilation of the repro above takes 10+ hours (never managed to actually run to the end). When running with debug version of ILCompiler I hit the following assertion early on:

Asking for Array<T> MethodTable
   at ILCompiler.DependencyAnalysis.EETypeNode.OnMarked(NodeFactory context) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.Compiler\Compiler\DependencyAnalysis\EETypeNode.cs:line 1331
   at ILCompiler.DependencyAnalysisFramework.DependencyNodeCore`1.CallOnMarked(DependencyContextType context) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyNodeCore.cs:line 134
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.AddToMarkStack(DependencyNodeCore`1 node, String reason, DependencyNodeCore`1 reason1, DependencyNodeCore`1 reason2) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 363
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1 node) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 187
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependencies(DependencyNodeCore`1 node) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 222
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 257
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 308
   at ILCompiler.RyuJitCompilation.CompileInternal(String outputFile, ObjectDumper dumper) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.RyuJit\Compiler\RyuJitCompilation.cs:line 88
   at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String outputFile, ObjectDumper dumper) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.Compiler\Compiler\Compilation.cs:line 523
   at ILCompiler.Program.Run() in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler\Program.cs:line 545
   at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass215_0.<.ctor>b__0(InvocationContext context) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler\ILCompilerRootCommand.cs:line 286
   at System.CommandLine.Invocation.AnonymousCommandHandler.Invoke(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<BuildInvocationChain>b__0(InvocationContext invocationContext, Func`2 _)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseErrorReporting>b__0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<UseParseErrorReporting>b__0(InvocationContext context, Func`2 next)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseHelp>b__0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<UseHelp>b__0(InvocationContext context, Func`2 next)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<UseVersionOption>b__0(InvocationContext context, Func`2 next)
   at System.CommandLine.Invocation.InvocationPipeline.<Invoke>g__FullInvocationChain|3_0(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(IConsole console)
   at ILCompiler.Program.Main(String[] args) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler\Program.cs:line 709

Note: The assemblies were preprocessed with Xamarin ILLink steps with the following PRs applied - xamarin/xamarin-macios#18524, xamarin/xamarin-macios#18519, and xamarin/xamarin-macios#18421

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 1, 2023
@ghost
Copy link

ghost commented Jul 1, 2023

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

Issue Details

Repro: https://1drv.ms/u/s!AgaMhbe7wFq8m8MQC0XPpTlHpadgrg?e=uS9Aqw

I was trying to debug why compilation of the repro above takes 10+ hours (never managed to actually run to the end). When running with debug version of ILCompiler I hit the following assertion early on:

Asking for Array<T> MethodTable
   at ILCompiler.DependencyAnalysis.EETypeNode.OnMarked(NodeFactory context) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.Compiler\Compiler\DependencyAnalysis\EETypeNode.cs:line 1331
   at ILCompiler.DependencyAnalysisFramework.DependencyNodeCore`1.CallOnMarked(DependencyContextType context) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyNodeCore.cs:line 134
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.AddToMarkStack(DependencyNodeCore`1 node, String reason, DependencyNodeCore`1 reason1, DependencyNodeCore`1 reason2) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 363
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1 node) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 187
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependencies(DependencyNodeCore`1 node) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 222
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 257
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.DependencyAnalysisFramework\DependencyAnalyzer.cs:line 308
   at ILCompiler.RyuJitCompilation.CompileInternal(String outputFile, ObjectDumper dumper) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.RyuJit\Compiler\RyuJitCompilation.cs:line 88
   at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String outputFile, ObjectDumper dumper) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler.Compiler\Compiler\Compilation.cs:line 523
   at ILCompiler.Program.Run() in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler\Program.cs:line 545
   at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass215_0.<.ctor>b__0(InvocationContext context) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler\ILCompilerRootCommand.cs:line 286
   at System.CommandLine.Invocation.AnonymousCommandHandler.Invoke(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<BuildInvocationChain>b__0(InvocationContext invocationContext, Func`2 _)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseErrorReporting>b__0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<UseParseErrorReporting>b__0(InvocationContext context, Func`2 next)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseHelp>b__0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<UseHelp>b__0(InvocationContext context, Func`2 next)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<UseVersionOption>b__0(InvocationContext context, Func`2 next)
   at System.CommandLine.Invocation.InvocationPipeline.<Invoke>g__FullInvocationChain|3_0(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(IConsole console)
   at ILCompiler.Program.Main(String[] args) in C:\Users\filip_pq4cffv\Documents\runtime\src\coreclr\tools\aot\ILCompiler\Program.cs:line 709

Note: The assemblies were preprocessed with Xamarin ILLink steps with the following PRs applied - xamarin/xamarin-macios#18524, xamarin/xamarin-macios#18519, and xamarin/xamarin-macios#18421

Author: filipnavara
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@filipnavara
Copy link
Member Author

Apparently basically all the assemblies end up as --root on the ILC command line. I'm going back in the MSBuild chain to figure out how that happened.

@filipnavara
Copy link
Member Author

Looks like this may affect any publish with -c Debug for Xamarin+NativeAOT. In that configuration it uses copy trim mode by default and it ends up having some unintended side effects. It's fine if that's unsupported but it should be caught early instead of running for hours with no error.

cc @ivanpovazan

@filipnavara
Copy link
Member Author

Interestingly, it also fails in release mode but at least it produces some warning:

/Users/filipnavara/Projects/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-preview.7.23328.2/packs/Microsoft.macOS.Sdk/13.3.8657-ci.macos-nativeaot-wip/targets/Xamarin.Shared.Sdk.targets(501,3): warning : All assemblies must be processed by the linker when using NativeAOT. Please don't set neither the 'LinkMode' nor the 'TrimMode' property, so that the build can default to linking all assemblies. [/Users/filipnavara/Projects/emclient/MailClient/MailClient.csproj::TargetFramework=net8.0-macos]

There may be something wrong in the project file (although it doesn't obviously set TrimMode or LinkMode in the .csproj files). I'll close the issue until I can provide some meaningful details.

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jul 1, 2023
@filipnavara
Copy link
Member Author

This seems to be caused by inverted condition: xamarin/xamarin-macios#18530

@ghost ghost locked as resolved and limited conversation to collaborators Jul 31, 2023
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

1 participant