[Mono-dev] Bug in MCS or Mono Runtime 1.2.6

Bill Holmes billholmes54 at gmail.com
Fri Dec 28 16:19:06 EST 2007


I have been able to reproduce this with the 1.2.6_4 install on
Windows.  I was able to compile the library and exe using csc and it
does run fine on Mono.  Also I have compiled using gmcs and run with
the MS runtime and I get the following exception.

Unhandled Exception: System.InvalidProgramException: Common Language
Runtime detected an invalid program.
   at Sample.MainWindow..ctor()
   at Sample.MainClass.Main(String[] args)

It appears that this is a mcs bug.

After further investigation I have a smaller sample that shows the
bug.  It occurs when you have a unconditional return statement before
a local variable declaration that is assigned inside an anonymous
delegate.  If you move the variable declaration above the return
statement the bug goes away.

I have also verified that this still occurs at the trunk version.
Mono JIT compiler version 1.2.6 (/trunk/ r92000)

I would suggest filing a compiler bug for this.

public class Test
{
    static public void TestFunc ()
    {
        return;

        string testStr;

        System.AppDomain.CurrentDomain.AssemblyLoad += delegate
(object Sender, System.AssemblyLoadEventArgs e)
        {
            testStr = "sss";
        };
    }

    public static void Main (string[] args)
    {
        TestFunc ();
    }
}


On Dec 27, 2007 6:24 PM, Laurent Debacker <debackerl at gmail.com> wrote:
> Hi,
>
> I'm developing a Gtk# application using MonoDevelop Beta 2 and Mono 1.2.6.
> However Mono could not execute the compiled assembly. The error provided is
> the following one:
>
> > Unhandled Exception: System.InvalidProgramException: Invalid IL code in
> Sample.MainWindow:.ctor (): IL_007e: nop
> >
> >
> >   at Sample.MainClass.Main (System.String[] args) [0x0000f] in
> /home/gizmo/Sample/Main.cs:12
> >
>
> I have attached both the generated assembly, and the tarball generated by
> MonoDevelop.
>
> For your conveniance, I have copy-pasted the IL code as dissasembled by
> Reflector of Sample.MainWindow:.ctor () is:
>
>
>
>  .method public hidebysig specialname
> rtspecialname instance void
> .ctor() cil managed
> {
>  .maxstack 12
>
> .locals init (
>  [0] class
> Sample.MainWindow/<>c__CompilerGenerated0
>  generated,
>  [1] class [
> gtk-sharp]Gtk.VBox box,
>  [2
> ] class [Ribbons]
> Ribbons.Button button,
>  [3] class [
> gtk-sharp]Gtk.Menu menu,
>  [4
> ] class [
> gtk-sharp]Gtk.MenuItem item,
>  [
> 5] class [
> gtk-sharp]Gtk.MenuItem item2,
>  [
> 6] class [Ribbons]
> Ribbons.Button button2,
>  [7] class [
> Ribbons]Ribbons.Button button3,
>  [8]
> class [gtk-sharp
> ]Gtk.Menu menu2,
>  [9]
> class [gtk-sharp
> ]Gtk.MenuItem item3,
>  [10
> ] class [Ribbons]
> Ribbons.ToolPack pack,
>  [11] class [
> Ribbons]Ribbons.ToolPack pack2,
>  [12
> ] class [Ribbons]
> Ribbons.ToolPack pack3,
>  [13] class [
> gtk-sharp]Gtk.ComboBox box2,
>  [
> 14] class Sample.MainWindow/
> <>c__CompilerGenerated1 generated2,
>  [15] class [
> gtk-sharp]Gtk.HBox box3,
>  [16
> ] class [
> gtk-sharp]Gtk.HBox box4,
>  [17
> ] class [
> gtk-sharp]Gtk.HBox box5,
>  [18
> ] class [Ribbons]
> Ribbons.RibbonGroup group,
>  [19] class [
> gtk-sharp]Gtk.HBox box6,
>  [20
> ] class [
> gtk-sharp]Gtk.Label label,
>  [
> 21] class [
> gtk-sharp]Gtk.Label label2,
>  [
> 22] class [Ribbons]
> Ribbons.Button button4,
>  [23] class
> Sample.MainWindow/<>c__CompilerGenerated4
>  generated3,
>  [24] class [
> gtk-sharp]Gtk.MenuItem item4,
>  [
> 25] class [
> gtk-sharp]Gtk.TextView view)
>  L_0000:
> nop
>  L_0001: ldc.i4 1
>  L_0006:
> pop
>  L_0007: nop
>  L_0008:
> newobj instance void
> Sample.MainWindow/<>c__CompilerGenerated0
> ::.ctor()
>  L_000d:
> stloc.0
>  L_000e: ldarg.0
>  L_000f:
> ldc.i4.0
>  L_0010: call instance
> void [Ribbons]
> Ribbons.SyntheticWindow::.ctor(valuetype
>  [gtk-sharp]
> Gtk.WindowType)
>  L_0015: ldarg.0
>  L_0016:
> ldc.i4 0x304
>  L_001b: call instance
> void [gtk-sharp]
> Gtk.Widget::AddEvents(
> int32)
>  L_0020: ldarg.0
>  L_0021:
> ldstr "Hello World"
>  L_0026:
> newobj instance void [
> Ribbons]Ribbons.Button::
> .ctor(string)
>  L_002b:
> call instance void [
> gtk-sharp]Gtk.Container::
> Add(class [
> gtk-sharp]Gtk.Widget)
>  L_0030:
> ldarg.0
>  L_0031: ldc.i4 200
>  L_0036:
> ldc.i4 200
>  L_003b: call instance
> void [gtk-sharp]
> Gtk.Window::Resize(
> int32, int32)
>  L_0040:
> ldarg.0
>  L_0041: call instance
> void [gtk-sharp]
> Gtk.Widget::ShowAll()
>  L_0046:
> ret
>  L_0047: nop
>  L_0048:
> ldc.i4 2
>  L_004d: pop
>  L_004e:
> nop
>  L_004f: newobj instance
> void
> Sample.MainWindow/<>c__CompilerGenerated1
> ::.ctor()
>  L_0054:
> stloc.s generated2
>  L_0056: ldloc.s generated2
>
>  L_0058: ldloc.0
>  L_0059:
> stfld class Sample.MainWindow/
> <>c__CompilerGenerated0 Sample.MainWindow/
> <>c__CompilerGenerated1::
> <2:scope1>
>  L_005e: nop
>  L_005f:
> ldc.i4 3
>  L_0064: pop
>  L_0065:
> nop
>  L_0066: newobj instance
> void
> Sample.MainWindow/<>c__CompilerGenerated4
> ::.ctor()
>  L_006b:
> stloc.s generated3
>  L_006d: ldloc.s generated3
>
>  L_006f: ldloc.s generated2
>  L_0071:
> stfld class Sample.MainWindow/
> <>c__CompilerGenerated1 Sample.MainWindow/
> <>c__CompilerGenerated4::
> <3:scope2>
>  L_0076: ldloc.s generated3
>  L_0078:
> ldloc.0
>  L_0079: stfld class
> Sample.MainWindow/<>c__CompilerGenerated0
>  Sample.MainWindow/
> <>c__CompilerGenerated4::
> <3:scope1>
> }
>
>
> Have nice holidays,
> Laurent Debacker.
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>



More information about the Mono-devel-list mailing list