[Mono-bugs] [Bug 492330] New: Crash when calling Marshal.GetFunctionPointerForDelegate with delegate obtained from DynamicMethod

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Apr 6 02:00:59 EDT 2009


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


           Summary: Crash when calling
                    Marshal.GetFunctionPointerForDelegate with delegate
                    obtained from DynamicMethod
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.4.x
          Platform: x86
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: interop
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: alex at centroidcafe.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en)
AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16

Mono crashes on an attempt to get a function pointer for a delegate produced
from DynamicMethod.CreateDelegate(Type, Object).

Stacktrace:

  at (wrapper managed-to-native) object.__icall_wrapper_mono_delegate_to_ftnptr
(object) <0x00004>
  at (wrapper managed-to-native) object.__icall_wrapper_mono_delegate_to_ftnptr
(object) <0xffffffff>
  at (wrapper managed-to-native)
System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegateInternal
(System.Delegate) <0xffffffff>
  at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate
(System.Delegate) <0x00016>
  at MonoBugTestcase.MainClass.Main (string[]) <0x000fb>
  at (wrapper runtime-invoke)
MonoBugTestcase.MainClass.runtime_invoke_void_object
(object,intptr,intptr,intptr) <0xffffffff>
Abort trap

Reproducible: Always

Steps to Reproduce:
Test case:

class MainClass
    {
        public delegate void FooDelegate();
        public static void Main(string[] args)
        {
            MainClass m = new MainClass();
            DynamicMethod foo = new DynamicMethod("foo", typeof(void), new
Type[] { typeof(MainClass) });

            ILGenerator il = foo.GetILGenerator();
            il.Emit(OpCodes.Ret);

            Delegate del = foo.CreateDelegate(typeof(FooDelegate), m);
            IntPtr ptr = Marshal.GetFunctionPointerForDelegate(del);

            Console.WriteLine("Got fn ptr: {0}", ptr);
        }
    }
Actual Results:  
Crash.

Expected Results:  
Pointer should be obtained for delegate.

Affects Mono 2.4. Also happens with 2.2. Could not test if Microsoft's .NET
also crashes, but I think it's safe to assume this is a bug in Mono.

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


More information about the mono-bugs mailing list