Open vitek-karas opened 11 months ago
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas See info in area-owners.md if you want to be subscribed.
Author: | vitek-karas |
---|---|
Assignees: | - |
Labels: | `area-Tools-ILLink` |
Milestone: | - |
In Debug builds, this repro hits an assert:
Process terminated. Assertion failed.
at Mono.Linker.Dataflow.CompilerGeneratedCallGraph.TrackCall(MethodDefinition fromMethod, TypeDefinition toType) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Dataflow/CompilerGeneratedCallGraph.cs:line 33
at Mono.Linker.Dataflow.CompilerGeneratedState.<GetCompilerGeneratedStateForType>g__ProcessMethod|11_0(MethodDefinition method, <>c__DisplayClass11_0&) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Dataflow/CompilerGeneratedState.cs:line 212
at Mono.Linker.Dataflow.CompilerGeneratedState.GetCompilerGeneratedStateForType(TypeDefinition type) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Dataflow/CompilerGeneratedState.cs:line 226
at Mono.Linker.Dataflow.CompilerGeneratedState.TryGetCompilerGeneratedCalleesForUserMethod(MethodDefinition method, List`1& callees) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Dataflow/CompilerGeneratedState.cs:line 435
at Mono.Linker.Steps.MarkStep.MarkReflectionLikeDependencies(MethodIL methodIL, Boolean requiresReflectionMethodBodyScanner, MessageOrigin origin) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs:line 3786
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body, MessageOrigin origin) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs:line 3549
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs:line 3221
at Mono.Linker.Steps.MarkStep.MethodDefinitionNode.GetStaticDependencies(NodeFactory context) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Steps/MarkStep.MethodDefinitionNode.cs:line 34
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1 node) in /home/svbomer/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 182
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependencies(DependencyNodeCore`1 node) in /home/svbomer/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 222
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() in /home/svbomer/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 257
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in /home/svbomer/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 308
at Mono.Linker.Steps.MarkStep.Process() in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs:line 369
at Mono.Linker.Steps.MarkStep.Process(LinkContext context) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs:line 243
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker/Pipeline.cs:line 178
at Mono.Linker.Pipeline.Process(LinkContext context) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker/Pipeline.cs:line 167
at Mono.Linker.Driver.Run(ILogger customLogger) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker/Driver.cs:line 843
at Mono.Linker.Driver.Main(String[] args) in /home/svbomer/src/runtime/src/tools/illink/src/linker/Linker/Driver.cs:line 68
It's asserting because there's an async state machine type that doesn't match the expected compiler-generated names. The method
System.Void Kodeo.Doctum.CodeCheck::Requires(System.Threading.Tasks.Task`1<System.Boolean>,System.String)
has an AsyncStateMachineAttribute that points to the type Kodeo.Doctum.CodeCheck/c
.
Found the problem:
System.Void Kodeo.Doctum.EntityFramework.Extensions/g::a()
, which is the MoveNext
of an async state machine.IAsyncStateMachine::MoveNext
.)g::a()
doesn't match the compiler-generated names we look for, it's not cached:
https://github.com/dotnet/runtime/blob/2b5c5422b8359716fc0d5766487ea1a6527d7472/src/tools/illink/src/linker/Linker.Dataflow/CompilerGeneratedNames.cs#L23-L35isinst
instructions that we can potentially remove, and later try to remove them twice from the same method, causing the crash.The fix will be to somehow make MarkAndCheckRequiresReflectionMethodBodyScanner idempotent for the method in question, despite it not matching the expected name mangling scheme.
That looks like obfuscated code - if that's the case we should probably close it. None of our compiler generated code logic will work when it's renamed/obfuscated.
Repro:
dotnet new console
app.csproj
:dotnet publish
Stack trace:
/cc @LakshanF