[Mono-bugs] [Bug 74953][Maj] Changed - [GMCS] Converting array to IEnumerable<T>

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed May 18 19:31:51 EDT 2005


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 miguel at ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=74953

--- shadow/74953	2005-05-17 10:35:04.000000000 -0400
+++ shadow/74953.tmp.31600	2005-05-18 19:31:51.000000000 -0400
@@ -5,13 +5,13 @@
 OS Details: Ubuntu Linux 5.05 (Hoary)
 Status: NEW   
 Resolution: 
 Severity: Unknown
 Priority: Major
 Component: JIT
-AssignedTo: mono-bugs at ximian.com                            
+AssignedTo: martin at ximian.com                            
 ReportedBy: emrysk at gmail.com               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
 URL: 
 Summary: [GMCS] Converting array to IEnumerable<T>
 OtherBugsDependingOnThis: 74945
@@ -92,6 +92,83 @@
 [mscorlib]System.Collections.Generic.IEnumerable`1<!0>)
     IL_000b:  ret
   } // end of method X::Main
 ====
 
 And this is working fine on the MS runtime, but crashes with mono.
+
+------- Additional Comments From miguel at ximian.com  2005-05-18 19:31 -------
+Simpler test case:
+
+using System;
+using System.Collections.Generic;
+
+class X {
+	static byte [] x = new byte [] {100, 100};
+
+	static void Main ()
+	{
+		X <byte>.Y (x);
+	}
+	
+	
+}
+
+class X <T> {
+	public static void Y (IEnumerable <T> x)
+	{
+		IEnumerator<T> tor = x.GetEnumerator ();
+	}
+}
+
+The method X<byte>.Y is:
+
+  .method public hidebysig static void  Y(class
+[mscorlib]System.Collections.Generic.IEnumerable`1<!T> x) cil managed
+  {
+    // Code size       8 (0x8)
+    .maxstack  2
+    .locals init (class
+[mscorlib]System.Collections.Generic.IEnumerator`1<!T> V_0)
+    IL_0000:  ldarg.0    
+    IL_0001:  callvirt   instance class
+[mscorlib]System.Collections.Generic.IEnumerator`1<!0> class
+[mscorlib]System.Collections.Generic.IEnumerable`1<!T>::GetEnumerator()
+    IL_0006:  stloc.0
+    IL_0007:  ret
+  } // end of method X`1::Y
+
+Which gets JITed into:
+00000000 <X_1_Y>:
+   0:   55                      push   %ebp
+   1:   8b ec                   mov    %esp,%ebp
+   3:   83 ec 04                sub    $0x4,%esp
+   6:   c7 45 fc 00 00 00 00    movl   $0x0,0xfffffffc(%ebp)
+   d:   8b 45 08                mov    0x8(%ebp),%eax
+  10:   50                      push   %eax
+  11:   8b 00                   mov    (%eax),%eax
+  13:   8b 40 0c                mov    0xc(%eax),%eax
+  16:   8b 80 98 00 00 00       mov    0x98(%eax),%eax
+  1c:   ff 10                   call   *(%eax)
+  1e:   59                      pop    %ecx
+  1f:   89 45 fc                mov    %eax,0xfffffffc(%ebp)
+  22:   c9                      leave
+  23:   c3                      ret
+
+Now, here is what happens, the value loaded in offset 16 is zero,
+so the call "%eax" produces the segfault:
+
+The code at instructions 0x13 and 0x16 is produced by inssel.c's
+mini_emit_load_intf_reg_vtable, by the following code:
+
+12779		MONO_EMIT_NEW_LOAD_MEMBASE (s, ioffset_reg, vtable_reg,
+G_STRUCT_OFFSET (MonoVTable, interface_offsets));
+
+That is the 0xc($eax), $eax load
+12770			MONO_EMIT_NEW_LOAD_MEMBASE (s, intf_reg, ioffset_reg,
+klass->interface_id * SIZEOF_VOID_P);
+
+That is the 0x98($eax), $eax load
+
+And this is what results in a null value.  
+
+


More information about the mono-bugs mailing list