[Mono-bugs] [Bug 81917][Min] New - Crash compiling code that casts fixed-size array to pointer

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Jun 20 14:41:47 EDT 2007

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 makosoft at googlemail.com.


--- shadow/81917	2007-06-20 14:41:47.000000000 -0400
+++ shadow/81917.tmp.16021	2007-06-20 14:41:47.000000000 -0400
@@ -0,0 +1,114 @@
+Bug#: 81917
+Product: Mono: Compilers
+Version: 1.2
+OS Details: Gentoo Linux
+Status: NEW   
+Priority: Minor
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: makosoft at googlemail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: Crash compiling code that casts fixed-size array to pointer
+Description of Problem:
+In Mono 1.2.4, mcs/gmcs crash when attempting to compile code that 
+implicitly casts from a fixed-size char array within a struct to a char 
+Steps to reproduce the problem:
+1. Create a struct containing a fixed-sized char array.
+2. Write code that attempts to implicitly cast the char array in the 
+struct to a char pointer.
+3. Attempt to compile the code with mcs or gmcs.
+Example code (compile with the -unsafe command line option):
+public class aClass
+        public struct foo_t
+        {
+		public fixed char b[16];
+	};
+	public unsafe static void Main(string[] args) {
+		foo_t bar;
+		char* b_ptr = bar.b;
+	}
+Actual Results:
+mcs/gmcs crashes with a System.NullReferenceException:
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object
+  at Mono.CSharp.TypeManager.MemberLookup_FindMembers (System.Type t, 
+MemberTypes mt, BindingFlags bf, System.String name, System.Boolean& 
+used_cache) [0x00000]
+  at Mono.CSharp.TypeManager.RealMemberLookup (System.Type 
+invocation_type, System.Type qualifier_type, System.Type queried_type, 
+MemberTypes mt, BindingFlags original_bf, System.String name, IList 
+almost_match) [0x00000]
+  at Mono.CSharp.TypeManager.MemberLookup (System.Type invocation_type, 
+System.Type qualifier_type, System.Type queried_type, MemberTypes mt, 
+BindingFlags original_bf, System.String name, IList almost_match) 
+  at Mono.CSharp.Expression.MemberLookup (System.Type container_type, 
+System.Type qualifier_type, System.Type queried_type, System.String name, 
+MemberTypes mt, BindingFlags bf, Location loc) [0x00000]
+  at Mono.CSharp.Expression.MethodLookup (System.Type container_type, 
+System.Type queried_type, System.String name, Location loc) [0x00000]
+  at Mono.CSharp.Convert.GetConversionOperator (System.Type 
+container_type, Mono.CSharp.Expression source, System.Type target_type, 
+Boolean look_for_explicit) [0x00000]
+  at Mono.CSharp.Convert.UserDefinedConversion (Mono.CSharp.EmitContext 
+ec, Mono.CSharp.Expression source, System.Type target, Location loc, 
+Boolean look_for_explicit) [0x00000]
+  at Mono.CSharp.Convert.ImplicitUserConversion (Mono.CSharp.EmitContext 
+ec, Mono.CSharp.Expression source, System.Type target, Location loc) 
+  at Mono.CSharp.Convert.ImplicitConversion (Mono.CSharp.EmitContext ec, 
+Mono.CSharp.Expression expr, System.Type target_type, Location loc) 
+  at Mono.CSharp.Convert.ImplicitConversionRequired 
+(Mono.CSharp.EmitContext ec, Mono.CSharp.Expression source, System.Type 
+target_type, Location loc) [0x00000]
+  at Mono.CSharp.Assign.DoResolve (Mono.CSharp.EmitContext ec) [0x00000]
+  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, 
+ResolveFlags flags) [0x00000]
+  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) 
+  at Mono.CSharp.ExpressionStatement.ResolveStatement 
+(Mono.CSharp.EmitContext ec) [0x00000]
+  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec) 
+  at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000]
+  at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext 
+anonymous_method_host, Mono.CSharp.ToplevelBlock block, 
+Mono.CSharp.Parameters ip, IMethodData md, System.Boolean& unreachable) 
+  at Mono.CSharp.EmitContext.EmitTopBlock (IMethodData md, 
+Mono.CSharp.ToplevelBlock block) [0x00000]
+  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000]
+  at Mono.CSharp.Method.Emit () [0x00000]
+  at Mono.CSharp.TypeContainer.EmitType () [0x00000]
+  at Mono.CSharp.RootContext.EmitCode () [0x00000]
+  at Mono.CSharp.Driver.MainDriver (System.String[] args) [0x00000]
+  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000]
+Expected Results:
+The compiler should either compile the code successfully or fail 
+gracefully with an error message.
+How often does this happen? 
+Every time.
+Additional Information:

More information about the mono-bugs mailing list