Bug 1324 - Disabling linking causes crash
Summary: Disabling linking causes crash
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 4.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-10-06 19:42 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2011-10-06 22:29 UTC (History)
3 users (show)

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


Attachments
Test project (7.85 KB, application/zip)
2011-10-06 19:42 UTC, Rolf Bjarne Kvinge [MSFT]
Details
crash log (26.06 KB, text/plain)
2011-10-06 19:44 UTC, Rolf Bjarne Kvinge [MSFT]
Details


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] 2011-10-06 19:42:31 UTC
Created attachment 634 [details]
Test project

Open attached project, run on device. It will crash (see second attachment).

Now enable linking (either sdk or all assemblies), and verify that it doesn't crash.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2011-10-06 19:44:21 UTC
Created attachment 635 [details]
crash log
Comment 2 Rolf Bjarne Kvinge [MSFT] 2011-10-06 19:46:18 UTC
CC Sebastian, possible linker issue.

Reported in assistly #3077 (priority).
Comment 3 Sebastien Pouliot 2011-10-06 20:03:01 UTC
From a _pre-build_ look the Cut method is not used anywhere so the linker will (by design) remove it.

Since it's (likely) not present in the linked application that may be the reason why it does not crash. I will investigate further...
Comment 4 Sebastien Pouliot 2011-10-06 20:29:31 UTC
So:

a. No link: work on simulator, crash on device
b. Link SDK : work (normal since Cut method won't be removed)
c. Link all: work (Cut is not linked out, its [Export]'ed)

It will be fun to see why the linker can avoid that crash in the trampoline!
Comment 5 Sebastien Pouliot 2011-10-06 21:44:15 UTC
Linking does remove UIResponder.Cut, which use the same "cut:" selector but has different method signature, from monotouch.dll. 

I believe the device trampoline is calling the wrong one (while the simulator gets it right*) leading to the crash.

* by design or by chance (the code paths are very different)
Comment 6 Sebastien Pouliot 2011-10-06 22:03:10 UTC
and UIResponder.Cut is implemented to support UIResponderStandardEditActions protocol which defines 'cut:' as

	- (void)cut:(id)sender

where we implement it as

	[Export ("cut:")]
	void Cut ();

ref:
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIResponderStandardEditActions_Protocol/UIResponderStandardEditActions.html#//apple_ref/occ/instm/NSObject/cut:
Comment 7 Sebastien Pouliot 2011-10-06 22:29:42 UTC
The solution is to override Cut. Of course it's better if the right one is available - that's fixed in GIT and the old methods still exists and are marked [Obsolete] for backward compatibility.

public override void Cut (NSObject sender)
{
   Console.WriteLine ("MT4ever!");
}


revision: d0cd84830891c0e47590e46bb1afc27db65978e9 (master)
I'll backport to branches tomorrow morning