Bug 11452 - Arch check in anonymous method crashes the linker
Summary: Arch check in anonymous method crashes the linker
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.3.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2013-03-27 19:44 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2013-03-28 11:37 UTC (History)
2 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Rolf Bjarne Kvinge [MSFT] 2013-03-27 19:44:07 UTC
Repro:
* Link all assemblies.
* Add this anywhere:

var button = new UIButton ();
button.TouchCancel += delegate 
{
	if (MonoTouch.ObjCRuntime.Runtime.Arch == Arch.SIMULATOR) {
		// kaboom
	}
};

* Try to compile:

error MT2001: Could not link assemblies. Reason: Object reference not set to an instance of an object
--- inner exception
System.NullReferenceException: Object reference not set to an instance of an object
  at MonoTouch.Tuner.OptimizeGeneratedCodeSubStep.ProcessLoadStaticField (Mono.Cecil.MethodDefinition caller, Int32 i) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.OptimizeGeneratedCodeSubStep.ProcessMethod (Mono.Cecil.MethodDefinition m) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.OptimizeGeneratedCodeSubStep.ProcessMethods (ICollection c) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.OptimizeGeneratedCodeSubStep.ProcessType (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0 
  at Mono.Tuner.SubStepDispatcher.DispatchType (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0 
  at Mono.Tuner.SubStepDispatcher.BrowseTypes (ICollection types) [0x00000] in <filename unknown>:0 
  at Mono.Tuner.SubStepDispatcher.BrowseAssemblies (IEnumerable`1 assemblies) [0x00000] in <filename unknown>:0 
  at Mono.Tuner.SubStepDispatcher.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0 
  at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, Mono.Linker.LinkContext& context, System.Collections.Generic.List`1& assemblies) [0x00000] in <filename unknown>:0
Comment 2 Sebastien Pouliot 2013-03-28 08:00:15 UTC
The anonymous delegate must be marked with [CompilerGenerated] and satisfy the other chekcs (subclassing NSObject).
Comment 3 Sebastien Pouliot 2013-03-28 11:37:40 UTC
Fixed in 364462aab1b7a2327955c5d299c619c5d1a67cbb (master) w/unit tests