[Mono-bugs] [Bug 576775] New: p/invoke function pointers unsupported

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Feb 3 17:03:37 EST 2010


http://bugzilla.novell.com/show_bug.cgi?id=576775

http://bugzilla.novell.com/show_bug.cgi?id=576775#c0


           Summary: p/invoke function pointers unsupported
    Classification: Mono
           Product: MonoTouch
           Version: SVN
          Platform: Macintosh
        OS/Version: Mac
            Status: NEW
          Severity: Enhancement
          Priority: P5 - None
         Component: Runtime
        AssignedTo: gnorton at novell.com
        ReportedBy: zach.griswold at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0

Calling Marshal.GetDelegateForFunctionPointer or using a delegate as a return
type for a P/Invoke function causes the exception (delegate has an attribute
specifying that it should be marshaled as an unmanaged function pointer):

Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile
method '(wrapper managed-to-native) object:wrapper_native_0x4080cc (int,int)'
while running with --aot-only.

    at (wrapper managed-to-native) MathTester.Tester:GetMathFunc ()

    at MathTester.Tester.TestFunctionPointers () [0x00000] in <filename
unknown>:0 

    at MathTester.AppDelegate.buttonClicked (MonoTouch.UIKit.UIButton sender)
[0x00000] in <filename unknown>:0 

    at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x00000] in <filename
unknown>:0 

    at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in
<filename unknown>:0 

Reproducible: Always

Steps to Reproduce:
1. Create a native C function that returns a function pointer.
2. Define the C# delegate and set it to be marshaled as an unmanaged function
pointer.
3. Define the P/Invoke function in C# for the native C function that returns
the function pointer (either have it return an 'IntPtr' or the defined
delegate).
(4. If returning 'IntPtr' from the P/Invoke call, use
'GetDelegateForFunctionPointer' to cast the returned 'IntPtr' to the C#
delegate.)
Actual Results:  
Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile
method '(wrapper managed-to-native) object:wrapper_native_0x4080cc (int,int)'
while running with --aot-only.

    at (wrapper managed-to-native) MathTester.Tester:GetMathFunc ()

    at MathTester.Tester.TestFunctionPointers () [0x00000] in <filename
unknown>:0 

    at MathTester.AppDelegate.buttonClicked (MonoTouch.UIKit.UIButton sender)
[0x00000] in <filename unknown>:0 

    at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x00000] in <filename
unknown>:0 

    at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in
<filename unknown>:0 

Expected Results:  
We should be able to cast a native function pointer into a C# delegate (either
explicitly by using it as the return type of the P/Invoke function or via
Marshal.GetDelegateForFunctionPointer).

I haven't tested passing a C# delegate to a native C function to see if C->C#
via a delegate->function pointer works (via
Marshal.GetFunctionPointerForDelegate).

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list