[Mono-bugs] [Bug 770901] New: CompileAssemblyFromSource crashes with Object reference not set to an instance of an object

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Jul 11 13:09:19 UTC 2012


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

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


           Summary: CompileAssemblyFromSource crashes with Object
                    reference not set to an instance of an object
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.10.x
          Platform: All
        OS/Version: RHEL 6
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: C#
        AssignedTo: michael.miller at suse.com
        ReportedBy: nikki at trumphurst.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Created an attachment (id=498194)
 --> (http://bugzilla.novell.com/attachment.cgi?id=498194)
Source code for program above

User-Agent:       Mozilla/5.0 (Windows NT 5.2; WOW64) AppleWebKit/536.11
(KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11

Calling CompileAssemblyFromSource sometimes causes the compiler to crash. The
compiler error list gets corrupted with part of the compiler stack trace.

I have narrowed the problem down to produce a minimal program to reproduce the
bug. However, in the real life code, the compiler crashes with different error
messages.

Reproducible: Always

Steps to Reproduce:
Compile the following code, then run it:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Reflection;
using Microsoft.CSharp;

namespace MonoCompilerBug {
    class Program {
        static void Main(string[] args) {
            Dictionary<string, string> options = new Dictionary<string, string>
{ 
                    { "CompilerVersion", "v3.5" }
                };
            CSharpCodeProvider icc = new CSharpCodeProvider(options);
            CompilerParameters cp = new CompilerParameters();
            cp.ReferencedAssemblies.Add("System.dll");
            cp.ReferencedAssemblies.Add("System.Core.dll");
            cp.ReferencedAssemblies.Add("System.Xml.dll");
            cp.ReferencedAssemblies.Add("System.Xml.Linq.dll");
            cp.ReferencedAssemblies.Add("System.Data.dll");
            cp.ReferencedAssemblies.Add("Mono.Posix.dll");
            cp.ReferencedAssemblies.Add("MonoCompilerBug.exe");
            cp.CompilerOptions = "/t:library /optimize
/define:TRACE;MONO;LINUX";
            cp.GenerateInMemory = true;
            CompilerResults cr = icc.CompileAssemblyFromSource(cp, @"namespace
MonoCompilerBug {
    public class ModelCode : ModelBase {
    }
}");
            if (cr.Errors.Count > 0) {
                System.Console.WriteLine("{0} Compile errors:",
cr.Errors.Count);
                foreach (CompilerError error in cr.Errors) {
                    System.Console.WriteLine("{0}:{1}:{2}", error.Line,
error.Column, error.ErrorText);
                }
            } else {
                System.Console.WriteLine("Compiled OK");
            }
        }
    }

    public class ModelBase {
        public class Page<C> {
        }

        public class PageDictionary<T, C>
            where T : ModelBase.Page<C>, new() {
        }

    }

}

Actual Results:  
2 Compile errors:
2:22:Object reference not set to an instance of an object
2:22:Only assignment, call, increment, decrement, and new object expressions
can be used as a statement


Expected Results:  
Compiled OK

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


More information about the mono-bugs mailing list