Bugzilla – Bug 318099
[GMCS] missing method
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by dsilva@ccs.neu.edu 2005-05-27 15:50:30 MST ---- 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. ---- Additional Comments From dsilva@ccs.neu.edu 2005-05-27 15:52:51 MST ---- By the way, the error shows up regardless of whether the key is null or not. ---- Additional Comments From martin@ximian.com 2005-07-02 09:08:16 MST ---- The NullReferenceException is clearly NOTABUG. The `cannot find method' error in mono_find_method_constrained() is a duplicate of bug .... (forgot the bug number) .... I fixed yesterday. ---- Additional Comments From martin@ximian.com 2005-07-02 09:11:16 MST ---- The Nemerle guys were so nice of mentioning that bug # I was looking for in their blog - this one is a duplicate of #75429 :-) ---- Additional Comments From martin@ximian.com 2005-07-02 09:11:30 MST ---- *** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO75429 *** Unknown operating system unknown. Setting to default OS "Other". This bug was marked DUPLICATE in the database it was moved from. Changing resolution to "MOVED"