[Mono-bugs] [Bug 665788] New: Get method body on delegate created with DynamicMethod.CreateDelegate

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Jan 20 04:48:25 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=665788

https://bugzilla.novell.com/show_bug.cgi?id=665788#c0


           Summary: Get method body on delegate created with
                    DynamicMethod.CreateDelegate
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.8.x
          Platform: x86-64
        OS/Version: Linux
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: asl.pavel at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Description of Problem:
mono crashes if you try to get method body from dynamicly create delegate with
DynamicMethod.CreateDelegate

Steps to reproduce the problem:
1. Simple programm :

using System;
using System.Reflection;
using System.Reflection.Emit;

public static class DynamicMethodBody
{
    public static void Main()
    {
        // create simple dynamic method
        var method = new DynamicMethod ( "method", typeof (object),
            new Type[] { typeof (object) } );

        // generate body
        var gen = method.GetILGenerator ();
        gen.Emit (OpCodes.Ldarg_0);
        gen.Emit (OpCodes.Ret);

        // create delegate
        var function = (Func<object,object>) method.CreateDelegate
            (typeof(Func<object,object>));

        // make sure delegate works correctly
        Console.WriteLine (function ("some string"));

        // CRASH HERE
        Console.WriteLine (function.Method.GetMethodBody ());
    }
}

2. execute it

Actual Results:
some string
* Assertion: should not be reached at reflection.c:6970

Stacktrace:

  at (wrapper managed-to-native)
System.Reflection.MethodBase.GetMethodBodyInternal (intptr) <0x00049>
  at (wrapper managed-to-native)
System.Reflection.MethodBase.GetMethodBodyInternal (intptr) <0x00049>
  at System.Reflection.MethodBase.GetMethodBody (intptr) <0x0000f>
  at System.Reflection.MonoMethod.GetMethodBody () <0x00013>
  at DynamicMethodBody.Main () <0x00127>
  at (wrapper runtime-invoke) object.runtime_invoke_void
(object,intptr,intptr,intptr) <0x00081>

Native stacktrace:

    /usr/bin/mono-sgen() [0x48a616]
    /lib/libpthread.so.0(+0xf230) [0x7f32b463c230]
    /lib/libc.so.6(gsignal+0x35) [0x7f32b42fe675]
    /lib/libc.so.6(abort+0x186) [0x7f32b42ffaf6]
    /usr/bin/mono-sgen() [0x5df72a]
    /usr/bin/mono-sgen() [0x5df857]
    /usr/bin/mono-sgen(mono_method_body_get_object+0x1a7) [0x51cb67]
    [0x403fe58a]

Debug info from gdb:

[Thread debugging using libthread_db enabled]
[New Thread 0x7f32b35f2700 (LWP 24283)]
0x00007f32b463b38d in read () from /lib/libpthread.so.0
  2 Thread 0x7f32b35f2700 (LWP 24283)  0x00007f32b463a5c0 in sem_wait () from
/lib/libpthread.so.0
* 1 Thread 0x7f32b50c7780 (LWP 24282)  0x00007f32b463b38d in read () from
/lib/libpthread.so.0

Thread 2 (Thread 0x7f32b35f2700 (LWP 24283)):
#0  0x00007f32b463a5c0 in sem_wait () from /lib/libpthread.so.0
#1  0x00000000005cca18 in mono_sem_wait ()
#2  0x00000000004e08cd in ?? ()
#3  0x000000000054d605 in ?? ()
#4  0x00000000005bcb14 in ?? ()
#5  0x00000000004e5b38 in ?? ()
#6  0x00007f32b4633cb0 in start_thread () from /lib/libpthread.so.0
#7  0x00007f32b439faed in clone () from /lib/libc.so.6
#8  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f32b50c7780 (LWP 24282)):
#0  0x00007f32b463b38d in read () from /lib/libpthread.so.0
#1  0x000000000048a79e in ?? ()
#2  <signal handler called>
#3  0x00007f32b42fe675 in raise () from /lib/libc.so.6
#4  0x00007f32b42ffaf6 in abort () from /lib/libc.so.6
#5  0x00000000005df72a in ?? ()
#6  0x00000000005df857 in ?? ()
#7  0x000000000051cb67 in mono_method_body_get_object ()
#8  0x00000000403fe58a in ?? ()
#9  0x00000000019827c0 in ?? ()
#10 0x0000000001982cc0 in ?? ()
#11 0x0000000000000000 in ?? ()

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Aborted

Expected Results:
some string
some string


How often does this happen?
always


Additional Information:

-- 
Configure bugmail: https://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