Bug 29970

Summary: [MonoNativeFunctionWrapper] doesn't work with methods that return structures on 32bit device
Product: iOS Reporter: Rolf Bjarne Kvinge [MSFT] <rolf>
Component: XI runtimeAssignee: Zoltan Varga <vargaz>
Status: VERIFIED FIXED    
Severity: normal CC: mono-bugs+monotouch, rolf, sebastien, shrutis, vdwork
Priority: ---    
Version: XI 8.10   
Target Milestone: Untriaged   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Test case
bug29970.zip
bug29970-b.zip

Description Rolf Bjarne Kvinge [MSFT] 2015-05-12 09:11:46 UTC
Created attachment 11162 [details]
Test case

Repro:
* Run the attached test project on device (in 32-bit mode).

Result:
> Attempting to JIT compile method '(wrapper delegate-invoke) <Module>:invoke_bound_CGSize_intptr&_intptr_intptr_intptr (intptr,intptr,intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
 (System.ExecutionEngineException)

If SizeWithAttributesDelegate is modified to return void, this exception does not occur (but obviously the test project crashes just after, since the arguments end up all wrong).
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-05-12 09:12:19 UTC
@Zoltan, can you have a look?
Comment 2 Zoltan Varga 2015-05-14 12:38:33 UTC
Fixed in mono master e9931382272870b086401d726147f59ea72a696e.
Comment 4 v7d 2015-05-26 15:46:51 UTC
What is the expected release for this fix?
Comment 7 Shruti 2015-05-27 09:16:52 UTC
Before verify, I need to reproduce this issue so I have deployed attached Test case sample project on 4S 32 bit device. It is deploying successfully on device and displaying text 'here is a test'. 

I have tried it with X.iOS 8.10.0.256, 8.10.0.258, 8.10.0.303

Can you please let me know how I can able to reproduce this issue.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2015-05-27 10:41:13 UTC
Created attachment 11358 [details]
bug29970.zip

@Shruti, can you try this project instead?
Comment 9 Shruti 2015-05-27 10:58:03 UTC
I have tried again with project given in comment(8), unfortunately still not able to reproduce it. I used X.iOS  8.10.0.258, 8.10.0.303 to reproduce this issue.
Comment 10 Rolf Bjarne Kvinge [MSFT] 2015-05-27 11:01:28 UTC
@Shruti, That's very strange, I have 8.10.0.267 and the app crashes on startup on my iPad Air (Debug configuration). Can you make sure you clean the solution between each XI re-install?
Comment 11 Rolf Bjarne Kvinge [MSFT] 2015-05-28 04:55:51 UTC
@Sebastien, can you try the project in comment 8 on device and see if it crashes for you at launch?
Comment 12 Sebastien Pouliot 2015-05-28 09:13:43 UTC
With 8.10.1 (macios-cycle5's head) on an iPod Touch 5th gen (32bits) I get this:

2015-05-28 09:08:20.233 MethodSwizzle[1000:432606] Unhandled managed exception:
Attempting to JIT compile method '(wrapper delegate-invoke) <Module>:invoke_bound_CGSize_intptr&_intptr_intptr_intptr (intptr,intptr,intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
 (System.ExecutionEngineException)
  at MethodSwizzle.Application.newSizeWithAttributes (IntPtr self, IntPtr sel, IntPtr dictionary) [0x00054] in /Users/poupou/Downloads/bug29970/Main.cs:166 
  at (wrapper native-to-managed) MethodSwizzle.Application:newSizeWithAttributes (intptr,intptr,intptr)
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/poupou/git/xamarin/maccore/src/UIKit/UIApplication.cs:63 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0001c] in /Users/poupou/git/xamarin/maccore/src/UIKit/UIApplication.cs:46 
  at MethodSwizzle.Application.Main (System.String[] args) [0x0001c] in /Users/poupou/Downloads/bug29970/Main.cs:26 

which is identical to the first reported exception.
Comment 13 Rolf Bjarne Kvinge [MSFT] 2015-05-28 09:21:45 UTC
@Shruti, can you try removing the app from the device before cleaning the solution and running again?
Comment 14 Rolf Bjarne Kvinge [MSFT] 2015-05-29 06:17:24 UTC
Created attachment 11385 [details]
bug29970-b.zip

@Shruti, can you try this test project now?

If it still doesn't fail, please get the output in the Application Output (nothing else is needed).
Comment 15 Shruti 2015-05-29 09:26:36 UTC
First I have reproduced this issue with attached project bug29970-b using X.iOS  8.10.0.256 . Getting exception when application is launched.  Here is the screencast for same : http://www.screencast.com/t/jiWDmffK8

Then I have verified this issue with X.iOS  8.11.0.868. Now it is working fine with this build. I am able to deploy and launch the app successfully.
Screencast regarding same:  http://www.screencast.com/t/NiR3KXE9De8

Environment Info:
=== Xamarin Studio ===

Version 5.9.2 (build 2)
Installation UUID: 67eaf3b4-f8a7-4ab4-a9df-3197350ca5dc
Runtime:
	Mono 4.0.1 ((detached/ed1d3ec)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400010044

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.Mac ===

Version: 2.0.1.64 (Enterprise Edition)

=== Xamarin.Android ===

Version: 5.1.2.1 (Enterprise Edition)
Android SDK: /Users/ixamarin78/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: 8.11.0.868 (Enterprise Edition)
Hash: 41e42d6
Branch: master
Build date: 2015-05-26 15:31:07-0400

=== Build Information ===

Release ID: 509020002
Git revision: 43735a4b905b571f69cf9428a3ea7b52aef55476
Build date: 2015-05-18 09:38:12-04
Xamarin addins: ab18ddff45f507ed74f36c2b65df9aee22e28a56

=== Operating System ===

Mac OS X 10.10.3
Darwin XamnewiMac.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64