[Mono-bugs] [Bug 70219][Nor] New - Compiler crash on Regex.Replace in struct

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 4 Dec 2004 23:27:49 -0500 (EST)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jhill@arcfocus.com.


--- shadow/70219	2004-12-04 23:27:49.000000000 -0500
+++ shadow/70219.tmp.3786	2004-12-04 23:27:49.000000000 -0500
@@ -0,0 +1,88 @@
+Bug#: 70219
+Product: Mono: Compilers
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jhill@arcfocus.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Compiler crash on Regex.Replace in struct
+Description of Problem:
+The following test case will compile fine on csc, but mcs will fail with a
+NullReferenceException.  If you change the struct to a class, the
+compilation will succeed.
+Steps to reproduce the problem:
+1.  Create x.cs file with the following code:
+using System;
+using System.Text.RegularExpressions;
+public struct X
+  private string GetXHtml(string input) {
+    return Regex.Replace("", "", new MatchEvaluator(X.XEval));
+  }
+  static string XEval(Match m) {
+    return m.ToString().ToLower();
+  }
+2. Attempt to compile:
+mcs x.cs -t:library
+Actual Results:
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+in <0x00013> Mono.CSharp.EmptyCast:.ctor (Mono.CSharp.Expression,System.Type)
+in <0x00014> Mono.CSharp.BoxedCast:.ctor (Mono.CSharp.Expression)
+in <0x004ca> Mono.CSharp.DelegateCreation:ResolveMethodGroupExpr
+in <0x00123> Mono.CSharp.NewDelegate:DoResolve (Mono.CSharp.EmitContext)
+in <0x000e8> Mono.CSharp.Expression:Resolve
+in <0x0001d> Mono.CSharp.Expression:Resolve (Mono.CSharp.EmitContext)
+in <0x00133> Mono.CSharp.New:DoResolve (Mono.CSharp.EmitContext)
+in <0x000e8> Mono.CSharp.Expression:Resolve
+in <0x0001d> Mono.CSharp.Expression:Resolve (Mono.CSharp.EmitContext)
+in <0x00196> Mono.CSharp.Argument:Resolve
+in <0x001f1> Mono.CSharp.Invocation:DoResolve (Mono.CSharp.EmitContext)
+in <0x000e8> Mono.CSharp.Expression:Resolve
+in <0x0001d> Mono.CSharp.Expression:Resolve (Mono.CSharp.EmitContext)
+in <0x00122> Mono.CSharp.Return:Resolve (Mono.CSharp.EmitContext)
+in <0x0017e> Mono.CSharp.Block:Resolve (Mono.CSharp.EmitContext)
+in <0x00113> Mono.CSharp.EmitContext:ResolveTopBlock
+in <0x00030> Mono.CSharp.EmitContext:EmitTopBlock
+in <0x00469> Mono.CSharp.MethodData:Emit
+in <0x00027> Mono.CSharp.Method:Emit ()
+in <0x0062a> Mono.CSharp.TypeContainer:EmitType ()
+in <0x004a4> Mono.CSharp.RootContext:EmitCode ()
+in <0x00cff> Mono.CSharp.Driver:MainDriver (string[])
+in <0x00019> Mono.CSharp.Driver:Main (string[])
+Expected Results:
+Compilation succeeded
+How often does this happen? 
+Additional Information:
+When mcs fails, it will not output a file name or number, making this issue
+difficult to track in larger projects.