Bug 12543 - NSObject.Invoke ends up crashing the app
Summary: NSObject.Invoke ends up crashing the app
Status: VERIFIED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.10.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: 2.0.x
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2013-06-04 14:47 UTC by Jérémie Laval
Modified: 2015-03-02 13:11 UTC (History)
3 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:
VERIFIED FIXED

Description Jérémie Laval 2013-06-04 14:47:33 UTC
Code anywhere in an NSObject: Invoke (() => Console.WriteLine ("Foo"), TimeSpan.FromSeconds (4));

Result:

2013-06-04 14:43:17.755 ReproMenuItem[72736:1207] -[MainWindowController xamarinApplySelector]: unrecognized selector sent to instance 0x4574c30
2013-06-04 14:43:17.756 ReproMenuItem[72736:1207] -[MainWindowController xamarinApplySelector]: unrecognized selector sent to instance 0x4574c30
2013-06-04 14:43:17.806 ReproMenuItem[72736:1207] (
	0   CoreFoundation                      0x9ab6ca67 __raiseError + 231
	1   libobjc.A.dylib                     0x977b6149 objc_exception_throw + 155
	2   CoreFoundation                      0x9ab70070 -[NSObject doesNotRecognizeSelector:] + 256
	3   CoreFoundation                      0x9aabecd9 ___forwarding___ + 457
	4   CoreFoundation                      0x9aabeaa2 _CF_forwarding_prep_0 + 50
	5   Foundation                          0x9355d792 __NSFireDelayedPerform + 615
	6   CoreFoundation                      0x9aa842a6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
	7   CoreFoundation                      0x9aa83c37 __CFRunLoopDoTimer + 743
	8   CoreFoundation                      0x9aa62cd0 __CFRunLoopRun + 1888
	9   CoreFoundation                      0x9aa621dc CFRunLoopRunSpecific + 332
	10  CoreFoundation                      0x9aa62088 CFRunLoopRunInMode + 120
	11  HIToolbox                           0x9bc60543 RunCurrentEventLoopInMode + 318
	12  HIToolbox                           0x9bc678ab ReceiveNextEventCommon + 381
	13  HIToolbox                           0x9bc6771a BlockUntilNextEventMatchingListInMode + 88
	14  AppKit                              0x92624ee8 _DPSNextEvent + 678
	15  AppKit                              0x92624752 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 113
	16  AppKit                              0x92620ac1 -[NSApplication run] + 911
	17  AppKit                              0x928b1ac5 NSApplicationMain + 1054
	18  ???                                 0x043070bb 0x0 + 70283451
	19  ???                                 0x04306edc 0x0 + 70282972
	20  ???                                 0x000bcfdc 0x0 + 774108
	21  ???                                 0x000bd127 0x0 + 774439
	22  libmono-2.0.dylib                   0x0030d385 mono_jit_runtime_invoke + 741
	23  libmono-2.0.dylib                   0x004beefe mono_runtime_invoke + 126
	24  libmono-2.0.dylib                   0x004c3324 mono_runtime_exec_main + 420
	25  libmono-2.0.dylib                   0x004c3695 mono_runtime_run_main + 725
	26  libmono-2.0.dylib                   0x003759a5 mono_jit_exec + 149
	27  libmono-2.0.dylib                   0x00377f9f mono_main + 9711
	28  ReproMenuItem                       0x00003093 main + 2035
	29  ReproMenuItem                       0x00002895 start + 53
)
Comment 1 Chris Hamons 2015-02-23 15:05:01 UTC
Just dropping this in AwakeFromNib () on an NSWindow kills it:

			Invoke (() => Console.WriteLine ("Foo"), 4);

2015-02-23 14:03:53.802 YoDogIHeardYouLikedAMacHack[13910:1352687] -[MainWindow xamarinApplySelector]: unrecognized selector sent to instance 0x6d8fc30
2015-02-23 14:03:53.803 YoDogIHeardYouLikedAMacHack[13910:1352687] -[MainWindow xamarinApplySelector]: unrecognized selector sent to instance 0x6d8fc30
2015-02-23 14:03:53.804 YoDogIHeardYouLikedAMacHack[13910:1352687] (
	0   CoreFoundation                      0x94fbf1f3 __raiseError + 195
	1   libobjc.A.dylib                     0x92a34a2a objc_exception_throw + 276
	2   CoreFoundation                      0x94fc3d55 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
	3   CoreFoundation                      0x94efafb8 ___forwarding___ + 1032
	4   CoreFoundation                      0x94efab8e _CF_forwarding_prep_0 + 14
	5   Foundation                          0x97413486 __NSFireDelayedPerform + 489
	6   CoreFoundation                      0x94f04776 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
--snip--
	17  AppKit                              0x914bdaac -[NSApplication run] + 907
	18  AppKit                              0x91431730 NSApplicationMain + 2082
--snip--
	31  YoDogIHeardYouLikedAMacHack         0x00002145 start + 53
Comment 2 Chris Hamons 2015-02-23 15:25:05 UTC
This also fails on iOS.

Did this ever work?
Comment 3 Chris Hamons 2015-02-24 11:40:36 UTC
Fixed in master / 274a4d70e8a1e8f78e1d3801fb13ee9df8ba933d

Thanks for the report. Added a test to prevent it from breaking again in the future.
Comment 4 Rajneesh Kumar 2015-03-02 13:11:59 UTC
I have checked this issue with the following builds:

=== Xamarin Studio ===
Version 5.8 (build 1043)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
Mono 4.0.0 ((detached/2634099)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400000017
 Apple Developer ToolsXcode 6.1 (6604)
Build 6A1052d
Xamarin.Mac Version: 1.13.1.417 (Business Edition)
=== Build Information ===
Release ID: 508001043
Git revision: eeba4b77cc5ab021f9c5e2bddf16272e1f6b75d9
Build date: 2015-03-02 06:49:10-05
Xamarin addins: a58814e6e6034bf1169e758b92ead093a3f40404
Operating SystemMac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
Sun Aug 17 19:50:11 PDT 2014
root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64

I observed that this issue is working fine. Now I am able to run the application successfully, using the code provided in bug description.
Please refer the screencast fro the same: http://www.screencast.com/t/G6CWrT6TZvKx

This issue has been fixed, hence I am closing this issue.