Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
When you use the MonoTouch apis to dynamically add and remove targets for a gesture recognizer, MonoTouch fails to unregister the previous target. The end result is that an unknown selector is [???? target:] is sent to another object or a completely invalid address is treated as an objective C object. Both lead to application termination.
This is particularly problematic because using the normal UIGestureRecognizer constructor that take an Action<X> argument often leads to a reference cycle. Breaking these reference cycles led me to experience this crash.
Here is a sample project that demonstrates the issue.
I also note that the Action<NSObject> type for the callback could (should?) be of type Action<UIGestureRecognizer>.
This is the most common crash log that I see from this.
>mono-rt: at <unknown> <0xffffffff>
>mono-rt: at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string,intptr,intptr) <IL 0x000a6, 0xffffffff>
>mono-rt: at MonoTouch.UIKit.UIApplication.Main (string,string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:39
>mono-rt: at GestureRecognizerTargetIssue.Application.Main (string) [0x00008] in /Users/tj/Projects/GestureRecognizerTargetIssue/GestureRecognizerTargetIssue/Main.cs:17
>mono-rt: at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
>Got a SIGSEGV while executing native code. This usually indicates
>a fatal error in the mono runtime or one of the native libraries
>used by your application.
I have a limited number of crash reports that list the [XYZ target:] unknown selector error. Unfortunately the plain SIGSEGV above does not get reported via crash reporting mechanism, so seeing it requires actually being connected to a test device to observe the log.
A potential workaround would be to use the AddTarget(NSAction) overload instead of AddTarget(Action<NSObject>) overload.
This will probably not get into Xamarin.iOS 7.4, since we've started that release process already, but it will get into the next release (which would probably be 7.6).