Bug 18967 - Linker crashes with an attribute taking a null System.Type constructor parameter
Summary: Linker crashes with an attribute taking a null System.Type constructor parameter
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.2.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-04-11 20:29 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2014-04-11 20:37 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Rolf Bjarne Kvinge [MSFT] 2014-04-11 20:29:10 UTC
Test case:

	class TypeAttribute : Attribute {
	   public TypeAttribute (Type type) {}

	[Type (null)]
	public void NullTypeInAttribute ()

Crashes (LinkAll) with:
System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.Cecil.SignatureReader.ReadTypeReference () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElementValue (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElement (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArgument (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeConstructorArguments (Mono.Cecil.CustomAttribute attribute, Mono.Collections.Generic.Collection`1 parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.MetadataReader.ReadCustomAttributeSignature (Mono.Cecil.CustomAttribute attribute) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.CustomAttribute.<Resolve>m__1 (Mono.Cecil.CustomAttribute attribute, Mono.Cecil.MetadataReader reader) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.Read[CustomAttribute,CustomAttribute] (Mono.Cecil.CustomAttribute item, System.Func`3 read) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.CustomAttribute.Resolve () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.CustomAttribute.get_HasConstructorArguments () [0x00000] in <filename unknown>:0 
  at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArguments (Mono.Cecil.CustomAttribute ca) [0x00000] in <filename unknown>:0 
  at Mono.Linker.Steps.MarkStep.MarkCustomAttribute (Mono.Cecil.CustomAttribute ca) [0x00000] in <filename unknown>:0 
  at Xamarin.Linker.Steps.MobileMarkStep.MarkCustomAttribute (Mono.Cecil.CustomAttribute ca) [0x00000] in <filename unknown>:0 
  at Mono.Linker.Steps.MarkStep.MarkCustomAttributes (ICustomAttributeProvider provider) [0x00000] in <filename unknown>:0 
  at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0 
  at Xamarin.Linker.Steps.CoreMarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0
Comment 2 Rolf Bjarne Kvinge [MSFT] 2014-04-11 20:37:59 UTC

cecil/master: https://github.com/mono/cecil/commit/c56601ce978a9246eba17e19f1e5c15f49e4f102
monotouch/master: https://github.com/xamarin/monotouch/commit/53c3827455cbd6a470d5b64a13b6f445edb31187 (+parent commit).

QA: unit tests were added as well.