dotnet / runtime

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

[area-Tools-ILLink]: Failed on .NET MAUI CI for macOS build: Fatal error in IL Linker #108617

Open Eilon opened 2 weeks ago

Eilon commented 2 weeks ago

Description

AzDO build log: https://dev.azure.com/xamarin/public/_build/results?buildId=125088&view=logs&j=71979588-66ac-5e95-831a-69c8cd9b2cd2&t=acd19e4c-afbd-5efc-2769-76bfa657ccbb&l=24110

Here are some details from the log:

   Maui.Controls.Sample -> /Users/builder/azdo/_work/2/s/artifacts/bin/Maui.Controls.Sample/Release/net9.0-maccatalyst/maccatalyst-x64/Maui.Controls.Sample.dll
   Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
   Optimizing assemblies for size. This process might take a while.
 ILLink : error IL1012: IL Trimmer has encountered an unexpected error. Please report the issue at https://aka.ms/report-illink [/Users/builder/azdo/_work/2/s/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj::TargetFramework=net9.0-maccatalyst]
   Fatal error in IL Linker
   Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
      at System.Collections.Immutable.ImmutableArray`1.get_Item(Int32 index)
      at Mono.Linker.Dataflow.TrimAnalysisMethodCallPattern.Merge(ValueSetLattice`1 lattice, TrimAnalysisMethodCallPattern other)
      at Mono.Linker.Dataflow.TrimAnalysisPatternStore.Add(TrimAnalysisMethodCallPattern pattern)
      at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.HandleCall(MethodBody callingMethodBody, MethodReference calledMethod, Instruction operation, ValueNodeList methodParams)
      at Mono.Linker.Dataflow.MethodBodyScanner.HandleCall(MethodBody callingMethodBody, Instruction operation, Stack`1 currentStack, Dictionary`2 locals, InterproceduralState& interproceduralState, Int32 curBasicBlock)
      at Mono.Linker.Dataflow.MethodBodyScanner.Scan(MethodIL methodIL, InterproceduralState& interproceduralState)
      at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.Scan(MethodIL methodIL, InterproceduralState& interproceduralState)
      at Mono.Linker.Dataflow.MethodBodyScanner.InterproceduralScan(MethodIL startingMethodIL)
      at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.InterproceduralScan(MethodIL methodIL)
      at Mono.Linker.Steps.MarkStep.MarkReflectionLikeDependencies(MethodIL methodIL, Boolean requiresReflectionMethodBodyScanner, MessageOrigin origin)
      at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body, MessageOrigin origin)
      at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason)
      at Mono.Linker.Steps.MarkStep.ProcessQueue()
      at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
      at Mono.Linker.Steps.MarkStep.Process()
      at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
      at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
      at Mono.Linker.Pipeline.Process(LinkContext context)
      at Mono.Linker.Driver.Run(ILogger customLogger)
      at Mono.Linker.Driver.Main(String[] args)
 /Users/builder/.nuget/packages/microsoft.net.illink.tasks/9.0.0-rtm.24501.6/build/Microsoft.NET.ILLink.targets(96,5): error NETSDK1144: Optimizing assemblies for size failed. [/Users/builder/azdo/_work/2/s/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj::TargetFramework=net9.0-maccatalyst]
   Maui.Controls.Sample -> /Users/builder/azdo/_work/2/s/artifacts/bin/Maui.Controls.Sample/Release/net9.0/Maui.Controls.Sample.dll

Reproduction Steps

Not sure about exact repro. This is happening on a CI build on AzDO.

Expected behavior

No error.

Actual behavior

Error.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

dotnet-policy-service[bot] commented 2 weeks ago

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

sbomer commented 2 weeks ago

@Eilon thanks for reporting. We'll need more info to diagnose this. Would you be able to provide repro instructions, or create a repro following the instructions from @vitek-karas's repro tool at https://github.com/vitek-karas/illinkrepro?