Skip to content

Placing DAM on a Type array crashes illink #104761

Closed
@MichalStrehovsky

Description

@MichalStrehovsky

dotnet/BenchmarkDotNet#1960 (comment)

[2022/03/28 17:20:11][INFO]   Unhandled exception. System.InvalidOperationException: Operation is not valid due to the current state of the object.
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.GetValueNodeForCustomAttributeArgument(CustomAttributeArgument argument)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.ProcessAttributeDataflow(MethodDefinition method, IList`1 arguments)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArguments(CustomAttribute ca)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(CustomAttribute ca, DependencyInfo& reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider, DependencyInfo& reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkModule(ModuleDefinition module, DependencyInfo reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkField(FieldDefinition field, DependencyInfo& reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.MarkModule(ModuleDefinition module, DependencyInfo reason)
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.ProcessMarkedPending()
[2022/03/28 17:20:11][INFO]      at Mono.Linker.Steps.MarkStep.Initialize()

I think the bug is here:

https://github.com/dotnet/linker/blob/da3c743a606b300c245c312c8cd9b3238d110d65/src/linker/Linker.Dataflow/FlowAnnotations.cs#L441-L450

This falls into the Cecil footgun that resolving the type removes any signs of it ever being a constructed/parameterized type.

Metadata

Metadata

Assignees

Labels

area-Tools-ILLink.NET linker development as well as trimming analyzersin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions