[Mono-bugs] [Bug 75071][Nor] New - missing method

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri May 27 15:50:30 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 dsilva at ccs.neu.edu.

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

--- shadow/75071	2005-05-27 15:50:30.000000000 -0400
+++ shadow/75071.tmp.27360	2005-05-27 15:50:30.000000000 -0400
@@ -0,0 +1,129 @@
+Bug#: 75071
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: dsilva at ccs.neu.edu               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: missing method
+
+Description of Problem:
+
+I don't know if this is a bug in gmcs, the runtime, or the class library.
+
+Sample program:
+
+$ cat eq.cs
+using System.Collections.Generic;
+using Mono.Cecil;
+
+public class App {
+  public static void Main() {
+    IDictionary<ITypeReference, string> typenames
+                 = new Dictionary<ITypeReference, string>();
+    string typename = typenames[null];
+  }
+}
+
+$ gmcs -debug -r:/home/dsilva/cvs/mono-svn/cecil/lib/Mono.Cecil.dll  eq.cs
+eq.cs(8) warning CS0219: The variable 'typename' is assigned but its value
+is never used
+Compilation succeeded - 1 warning(s)
+
+
+
+$ mono --debug eq.exe
+** (eq.exe:12910): WARNING **: Missing method Equals in assembly
+/usr/local/stow/mono-svn/lib/mono/2.0/mscorlib.dll token 6000002
+
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+in <0x00000> <unknown method>
+in [0x0000c] (at
+/home/dsilva/cvs/mono-svn/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:87)
+System.Collections.Generic.Dictionary`2<Mono.Cecil.ITypeReference,System.String>:get_Item
+(ITypeReference )
+in [0x00008] (at /tmp/eq.cs:9) App:Main ()
+
+
+So I changed the constructors for NullReferenceException to print a stack
+trace, then changed Dictionary.cs's index operator like this:
+
+  public V this [K key] {
+   get {
+    System.Console.WriteLine("Dictionary.get_Item: entry");
+    int index = GetSlot (key);
+    System.Console.WriteLine("Dictionary.get_Item: got the index");
+    if (index < 0) {
+      System.Console.WriteLine("Dictionary.get_Item: index is invalid");
+      throw new KeyNotFoundException ();
+      }
+    System.Console.WriteLine("Dictionary.get_Item: index is valid");
+    return _table [index].Value;
+  }
+
+
+then changed mono/metadata/loader.c's mono_get_method_constrained procedure
+to log a couple more things after the find_method call:
+
+result = find_method (constrained_class, ic, method->name,
+mono_method_signature (method));
+if (!result) {
+  g_warning("Constrained class address: 0x%x, ic address: 0x%x",
+             (unsigned int) constrained_class, (unsigned int) ic);
+  g_warning("Constrained class name address: 0x%x, ic name address: 0x%x",
+             (unsigned int) constrained_class->name,
+             (ic ? (unsigned int) ic->name : 0));
+  g_warning("Constrained class: %s, ic: %s", constrained_class->name,
+             (ic ? ic->name : "(no name, ic is null)"));
+  g_warning ("Missing method %s in assembly %s token %x", method->name,
+              image->name, token);
+}
+
+
+then ran the program again:
+
+$ mono --debug eq.exe
+
+         at System.NullReferenceException..ctor ()
+Dictionary.get_Item: entry
+
+** (eq.exe:12910): WARNING **: Constrained class address: 0x82af728, ic
+address: 0x0
+
+** (eq.exe:12910): WARNING **: Constrained class name address: 0xb72663aa,
+ic name address: 0x0
+
+** (eq.exe:12910): WARNING **: Constrained class: ITypeReference, ic: (no
+name, ic is null)
+
+** (eq.exe:12910): WARNING **: Missing method Equals in assembly
+/usr/local/stow/mono-svn/lib/mono/2.0/mscorlib.dll token 6000002
+
+         at System.NullReferenceException..ctor ()
+         at System.Collections.Generic.Dictionary`2.get_Item ()
+         at System.Collections.Generic.Dictionary`2.get_Item ()
+         at App.Main ()
+
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+in <0x00000> <unknown method>
+in [0x0000c] (at
+/home/dsilva/cvs/mono-svn/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:87)
+System.Collections.Generic.Dictionary`2<Mono.Cecil.ITypeReference,System.String>:get_Item
+(ITypeReference )
+in [0x00008] (at /tmp/eq.cs:9) App:Main ()
+$
+
+
+Note: I used Cecil's ITypeReference in the bug report because the problem
+doesn't appear when I use a value type or a class defined in the same file.


More information about the mono-bugs mailing list