Bug 14194 - 6.4.x doesn't AOT reverse-callback delegate
Summary: 6.4.x doesn't AOT reverse-callback delegate
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.4.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 6.4.4
Assignee: Zoltan Varga
URL:
: 14242 ()
Depends on:
Blocks:
 
Reported: 2013-08-22 17:45 UTC by Howard Lee
Modified: 2013-08-29 13:12 UTC (History)
5 users (show)

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


Attachments
Test case. (14.16 KB, application/zip)
2013-08-22 17:45 UTC, Howard Lee
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:
VERIFIED FIXED

Description Howard Lee 2013-08-22 17:45:06 UTC
Created attachment 4697 [details]
Test case.

After upgrading monotouch from 6.2.7.1 to 6.4.x, it now tries to JIT-compile a delegate passed to a native function if the delegate returns string. There's no problem passing delegates if the return type is int.

The same code works if I switch back to 6.2.7.1. Per http://docs.xamarin.com/guides/ios/advanced_topics/limitations the callback is both static and flagged with MonoPInvokeCallbackAttribute.

In contrast to some of the other JIT/AOT bugs, this exception always happens. Tests are run on a device (iPhone 4, iOS 6.1.3).

======================================================================
Exception:

Unhandled managed exception: Attempting to JIT compile method '(wrapper native-to-managed) WrapperTest.Foo:CreateCsString (intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
         (System.ExecutionEngineException)
          at (wrapper managed-to-native) object:__icall_wrapper_mono_delegate_to_ftnptr (object)
          at (wrapper managed-to-native) WrapperTest.Foo:register_callback (WrapperTest.Foo/Callback)
          at WrapperTest.Foo.DoSomething (System.String s) [0x0001e] in /Users/bob/testcase/WrapperTest/WrapperTest/Foo.cs:14
          at WrapperTest.WrapperTestViewController+<ViewDidLoad>c__AnonStorey0.<>m__1 () [0x00016] in /Users/bob/testcase/WrapperTest/WrapperTest/WrapperTestViewController.cs:22
          at MonoTouch.Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSAction.cs:87
          at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
          at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
          at WrapperTest.Application.Main (System.String[] args) [0x00008] in /Users/bob/testcase/WrapperTest/WrapperTest/Main.cs:16

======================================================================
About:

Xamarin Studio
Version 4.0.12 (build 3)
Installation UUID: e64f6dc1-db06-40fc-92bd-a1309741a57d
Runtime:
	Mono 3.2.0 ((no/7c7fcc7)
	GTK 2.24.20
	GTK# (2.12.0.0)
	Package version: 302000000

Apple Developer Tools
Xcode 4.6.1 (2067)
Build 4H512

Xamarin.Mac
Xamarin.Mac: Not Installed

Xamarin.iOS
Version: 6.4.3.0 (Business Edition)
Hash: 0068990
Branch:
Build date: 2013-13-08 05:24:39-0400

======================================================================
Comment 1 Sebastien Pouliot 2013-08-22 21:06:56 UTC
I get the same using (unreleased) 6.4.4.
Comment 2 Zoltan Varga 2013-08-23 17:20:07 UTC
Fixed in mono master 722ace9131ecc615a867fd770dfad4afa7f3c510. This is safe to backport everywhere.
Comment 4 Sebastien Pouliot 2013-08-26 14:08:51 UTC
*** Bug 14242 has been marked as a duplicate of this bug. ***
Comment 6 Zoltan Varga 2013-08-29 12:32:44 UTC
I get:

2013-08-29 18:29:08.994 WrapperTest[501:907] Unhandled managed exception: register_callback (System.EntryPointNotFoundException)
  at (wrapper managed-to-native) WrapperTest.Foo:register_callback (WrapperTest.Foo/Callback)
  at WrapperTest.Foo.DoSomething (System.String s) [0x00000] in <filename unknown>:0 
  at WrapperTest.WrapperTestViewController+<ViewDidLoad>c__AnonStorey0.<>m__1 () [0x00000] in <filename unknown>:0 
  at MonoTouch.Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0 
  at WrapperTest.Application.Main (System.String[] args) [0x00000] in <filename unknown>:0

because the Release configuration is not linking against the native library like the debug configuration does.
Comment 7 PJ 2013-08-29 13:12:38 UTC
Heyo,

When I link the native library in Release (adding -cxx -gcc_flags "-L${ProjectDir} -lfoo -force_load ${ProjectDir}/libfoo.a") the test case passes.

Thanks!