[Mono-bugs] [Bug 577821] New: Compiler generics implementation: regression in 2.6.1 causes compiler crash

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Feb 7 23:22:45 EST 2010


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

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


           Summary: Compiler generics implementation: regression in 2.6.1
                    causes compiler crash
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.6.x
          Platform: Macintosh
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: brian at sooloos.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User
           Blocker: ---


Description of Problem:

gmcs.exe crashes when compiling. This has been reproduced on mac os x (snow
leopard) and linux (ubuntu 9.10). On ubuntu, mono was built from 2.6.1 source
tarball. On mac os x, mono was installed using the 2.6.1 installer published on
the website.


Steps to reproduce the problem:

1. Save t.cs and u.cs
2. Execute the following commands:

$ gmcs -target:library u.cs -out:u.dll
$ gmcs t.cs /r:u.dll

--------------------- contents of t.cs ----------------------------

using System;
using System.Collections.Generic;

namespace Foo {
    using P = Baz.P;
    static class Bar
    {
        public static Baz.Frob<List<T>> MakeArrayParser<T>(string root, Quux<T>
quux)
        {
            return P.Element<List<T>>(root, v => v.Value = new List<T>(), v =>
P.Children(P.Child(quux("e"), x => v.Value.Add(x))));
        }
        public delegate Baz.Frob<T> Quux<T>(string s);
        public static void Main(string[] args) {}
    }
}

--------------------- contents of u.cs ----------------------------

using System;
using System.Xml;

namespace Baz
{
    public abstract class Frob<T> { }
    public abstract class Child<T> { }

    public abstract class Base
    {
        public delegate void Action<U>(U val);
    }

    public class Element<T> : Frob<T>
    {
        public delegate void Start(Ref val);
        public delegate void Children(Ref item);
        public class Ref { public T Value; }
    }

    public static class P
    {
        public static Element<T> Element<T>(string name, Element<T>.Start
start, Element<T>.Children children) { return null; }
        public static object Children(params Base[] children) { return null; }
        public static Base Child<U>(Frob<U> frob, Base.Action<U> action) {
return null; }
    }
}

----------------------------------------------------------------

Actual Results:

$ gmcs -target:library u.cs -out:u.dll
$ gmcs t.cs /r:u.dll

Unhandled Exception: System.ArgumentException: The field handle and the type
handle are incompatible.
  at System.Reflection.FieldInfo.GetFieldFromHandle (RuntimeFieldHandle handle,
RuntimeTypeHandle declaringType) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AnonymousMethodStorey.MutateField (System.Reflection.FieldInfo
field) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldExpr.MutateHoistedGenericType
(Mono.CSharp.AnonymousMethodStorey storey) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MemberExpr.MutateHoistedGenericType
(Mono.CSharp.AnonymousMethodStorey storey) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodGroupExpr.MutateHoistedGenericType
(Mono.CSharp.AnonymousMethodStorey storey) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Invocation.MutateHoistedGenericType
(Mono.CSharp.AnonymousMethodStorey storey) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Return.MutateHoistedGenericType
(Mono.CSharp.AnonymousMethodStorey storey) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.MutateHoistedGenericType
(Mono.CSharp.AnonymousMethodStorey storey) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AnonymousExpression+AnonymousMethodMethod.Emit () [0x00000] in
<filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AnonymousMethodStorey.EmitType () [0x00000] in <filename
unknown>:0 
  at Mono.CSharp.TypeContainer.EmitType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AnonymousMethodStorey.EmitType () [0x00000] in <filename
unknown>:0 
  at Mono.CSharp.TypeContainer.EmitType () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.RootContext.EmitCode () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename
unknown>:0 


Expected Results:

I would expect the compilation to succeed.


How often does this happen? 

Every time.


Additional Information:

This failure happened when compiling a project with over 500k lines of c# code
in hundreds of source files and dozens of assemblies. This case to reproduce
was found via a time consuming manual binary search process. If possible, it
would be great if the compiler could give more information when these kinds of
failures occur. Even minimal information about what module or method is being
processed at the time of the unexpected exception would have saved lots of time
in preparing this bug report.

The code compiles and runs properly using mono 2.4.2.3 and has been running in
production for us for quite a while with 2.4.2.3. This crash is new in the
2.6.x series. The code also compiles and runs properly using ms .net and has
been doing so for a while with ms.net 3.5 and 2.0.

Note that the failure does not occur unless the source files are compiled into
separate assemblies as described above. If I attempt to compile the two files
into the same assembly, the crash doesn't occur.

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