You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
ILLink : error IL1012: IL Linker has encountered an unexpected error. Please report the issue at https://github.com/mono/linker/issues [/Users/lluis/prog/work/vsmac/test/main/src/tools/vstool/vstool.csproj]
Fatal error in IL Linker
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Mono.Linker.CustomAttributeSource.HasAny(ICustomAttributeProvider provider)
at Mono.Linker.AnnotationStore.GetLinkerAttributes[T](IMemberDefinition member)
at Mono.Linker.AnnotationStore.TryGetLinkerAttribute[T](IMemberDefinition member, T& attribute)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
at Mono.Linker.Steps.MarkStep.MarkField(FieldDefinition field, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.ProcessMarkedPending()
at Mono.Linker.Steps.MarkStep.Initialize()
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)
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/6.0.100-rc.1.21458.32/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.ILLink.targets(108,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [/Users/lluis/prog/work/vsmac/test/main/src/tools/vstool/vstool.csproj]
@slluis are you able to share a repro? We think we know the issue but would like to be able to validate that it actually fixes the exception in your scenario.
So the warning is actually in the TryResolve call, which can return null. TryGetLinkerAttribute assumes that the provider is not null, we never check for it and end up using the null member to get its attributes.
We have two options:
Return an empty list of attributes as soon as we see the provider is null
Fail inside TryGetLinkerAttribute if it sees a null provider, and in MarkStep only get the attributes if the TryResolve was not null
I think I don't have a strong preference on either of those, and I will try to enable nullable on Annotations.cs as part of the PR
I would suggest fixing it in the caller in MarkStep and annotating the input to TryGetLinkerAttribute as non-nullable. Once everything is annotated this should ensure it never gets a null input. I personally wouldn't add any null check inside TryGetLinkerAttribute.
Activity
marek-safar commentedon Sep 15, 2021
/cc @vitek-karas
sbomer commentedon Sep 15, 2021
By inspection I think this could be caused by an unresolved base type here:
linker/src/linker/Linker.Steps/MarkStep.cs
Line 1822 in be8ec96
Turning on nullable annotations for
Annotations.cswill probably catch this issue too.sbomer commentedon Sep 16, 2021
@slluis are you able to share a repro? We think we know the issue but would like to be able to validate that it actually fixes the exception in your scenario.
agocke commentedon Sep 16, 2021
@tlakollo Can you turn on nullable here and confirm that we get a warning, and then fix the bug?
tlakollo commentedon Sep 16, 2021
So the warning is actually in the TryResolve call, which can return null. TryGetLinkerAttribute assumes that the provider is not null, we never check for it and end up using the null member to get its attributes.
We have two options:
I think I don't have a strong preference on either of those, and I will try to enable nullable on Annotations.cs as part of the PR
sbomer commentedon Sep 16, 2021
I would suggest fixing it in the caller in MarkStep and annotating the input to
TryGetLinkerAttributeas non-nullable. Once everything is annotated this should ensure it never gets a null input. I personally wouldn't add any null check insideTryGetLinkerAttribute.Port to 6.0 to fix dotnet#2274
slluis commentedon Sep 17, 2021
I verified the fix work using a local copy of the fixed linker 👍
Port Fix for TryResolve scenario (#2279)