Skip to content

NRE in SubStepsDispatcher #1458

@rolfbjarne

Description

@rolfbjarne

Test case: linkercustomsteptestcase-eb50a89.zip

Run the test.sh script to repro:

./test.sh
+ rm -Rf CustomStep/bin Executable/bin CustomStep/obj Executable/obj
+ dotnet build CustomStep/dotnet-linker.csproj
Microsoft (R) Build Engine version 16.8.0-preview-20425-03+384d02a5f for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /Users/rolf/test/linkercustomsteptestcase/CustomStep/dotnet-linker.csproj (in 96 ms).
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  dotnet-linker -> /Users/rolf/test/linkercustomsteptestcase/CustomStep/bin/Debug/net5.0/dotnet-linker.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.11
+ dotnet publish -r osx-x64 --self-contained true -p:MonoAOT=true -p:VM=mono -p:PublishTrimmed=true -p:TrimMode=link Executable/Executable.csproj /bl:x.binlog
Microsoft (R) Build Engine version 16.8.0-preview-20425-03+384d02a5f for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

/usr/local/share/dotnet/sdk/5.0.100-rc.1.20426.3/MSBuild.dll -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/local/share/dotnet/sdk/5.0.100-rc.1.20426.3/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/local/share/dotnet/sdk/5.0.100-rc.1.20426.3/dotnet.dll -maxcpucount -property:RuntimeIdentifier=osx-x64 -property:SelfContained=true -p:MonoAOT=true -p:VM=mono -p:PublishTrimmed=true -p:TrimMode=link -restore -target:Publish -verbosity:m /bl:x.binlog Executable/Executable.csproj
  Determining projects to restore...
  Restored /Users/rolf/test/linkercustomsteptestcase/Executable/Executable.csproj (in 87 ms).
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  Executable -> /Users/rolf/test/linkercustomsteptestcase/Executable/bin/Debug/net5.0/osx-x64/Executable.dll
ILLink : error IL1012: IL Linker has encountered an unexpected error. Please report the issue at https://github.com/mono/linker/issues [/Users/rolf/test/linkercustomsteptestcase/Executable/Executable.csproj]
  Fatal error in IL Linker
  Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
     at Mono.Linker.Steps.SubStepsDispatcher.DispatchType(TypeDefinition type)
     at Mono.Linker.Steps.SubStepsDispatcher.BrowseTypes(Collection`1 types)
     at Mono.Linker.Steps.SubStepsDispatcher.BrowseAssemblies(IEnumerable`1 assemblies)
     at Mono.Linker.Steps.SubStepsDispatcher.Mono.Linker.Steps.IStep.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)
  Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
/usr/local/share/dotnet/sdk/5.0.100-rc.1.20426.3/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.ILLink.targets(41,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [/Users/rolf/test/linkercustomsteptestcase/Executable/Executable.csproj]
$ dotnet --version
5.0.100-rc.1.20426.3

This seems to be when there's one substep that includes types, another that doesn't and they're active for different assemblies.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions