[Mono-bugs] [Bug 367663] New: ILGenerator.EmitCalli() doesn't handle null return type.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Mar 6 02:27:46 EST 2008


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


           Summary: ILGenerator.EmitCalli() doesn't handle null return type.
           Product: Mono: Class Libraries
           Version: 1.9.0
          Platform: Other
        OS/Version: Windows Vista
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jeroen at sumatra.nl
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


This program dies with an exception on Mono, but runs fine on Windows:

using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;

class Program
{
  static System.Threading.ThreadStart del = Foo;

  static void Main()
  {
    AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(new
AssemblyName("foo"), AssemblyBuilderAccess.Run);
    ModuleBuilder modb = ab.DefineDynamicModule("foo.dll");
    TypeBuilder tb = modb.DefineType("Foo");
    MethodBuilder mb = tb.DefineMethod("Frub", MethodAttributes.Static, null,
new Type[] { typeof(IntPtr) });
    mb.SetImplementationFlags(MethodImplAttributes.NoInlining);
    ILGenerator ilgen = mb.GetILGenerator();
    ilgen.Emit(OpCodes.Ldarg_0);
    // if you pass typeof(void) instead of null, it works
    ilgen.EmitCalli(OpCodes.Calli, CallingConvention.StdCall, null,
Type.EmptyTypes);
    ilgen.Emit(OpCodes.Ret);
    Type type = tb.CreateType();
    type.GetMethod("Frub", BindingFlags.NonPublic | BindingFlags.Static)
                        .Invoke(null, new object[] {
Marshal.GetFunctionPointerForDelegate(del) });
        }

  static void Foo()
  {
  }
}


-- 
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