Bugzilla – Bug 318313
[GMCS] references to static generic fields are compiled to unverifiable code
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by nazgul@omega.pl 2005-06-19 16:28:03 MST ---- Please fill in this template when reporting a bug, unless you know what you are doing. Description of Problem: When I have a reference to static field in generic class from external library it is emitted to IL with instanciated signature - csc, MS S.R.E, gmcs (for references in current assembly) produces noninstanciated signatures of generic member references, so I assume this is according to the spec. But when gmcs compile reference to external lib, the created assembly do not work on MS.NET 2.0 Beta 2 Steps to reproduce the problem: 1. Compile gmcs tlib.cs /t:library /out:tlib.dll public class A <T> { public static A<T> _N_constant_object = new A<T> (); } 2. Compile gmcs t.cs /r:tlib.dll class B<T> { public static B<T> _N_constant_object = new B<T> (); } class M { static void Main () { A<int> x = A<int>._N_constant_object; B<int> y = B<int>._N_constant_object; } } 3. Run on MS.NET ./t.exe Actual Results: Unhandled Exception: System.MissingFieldException: Field not found: 'A`1._N_constant_object'. at M.Main() Unknown signal 79 Expected Results: clear run How often does this happen? Always Additional Information: PEVerify.exe output: PEVerify .exe t.exe Microsoft (R) .NET Framework PE Verifier. Version 2.0.50215.44 Copyright (C) Microsoft Corporation. All rights reserved. [IL]: Error: [C:\cygwin\home\nazgul\nemerle\ncc\testsuite\t.exe : M::Main][offset 0x00000000] Field is not visible. 1 Error Verifying t.exe The problem can be seen in following IL: IL_0000: ldsfld class [tlib]A`1<int32> class [tlib]A`1<int32>::_N_constant_object IL_0005: stloc.0 IL_0006: ldsfld class B`1<!0> class B`1<int32>::_N_constant_object Also for external lib there should be class [tlib]A`1<!0> class ... This is a blocker for running nemerle compiler on MS.NET (because currently it can be currently only on mono) ---- Additional Comments From martin@ximian.com 2005-06-21 06:07:26 MST ---- Fixed in SVN. ---- Additional Comments From martin@ximian.com 2005-06-21 06:12:39 MST ---- *** https://bugzilla.novell.com/show_bug.cgi?id=MONO75312 has been marked as a duplicate of this bug. *** ---- Additional Comments From martin@ximian.com 2005-06-21 06:13:54 MST ---- *** https://bugzilla.novell.com/show_bug.cgi?id=MONO75313 has been marked as a duplicate of this bug. *** ---- Additional Comments From nazgul@omega.pl 2005-06-21 06:47:46 MST ---- I don't think this bug is solved. It seems to be a S.R.E or runtime issue. With 46295 gmcs still produces: IL_0000: ldsfld class [tlib]'A`1'<int32> class [tlib]'A`1'<int32>::_N_constant_object IL_0005: stloc.0 IL_0006: ldsfld class 'B`1'<!0> class 'B`1'<int32>::_N_constant_object (monodis also shows that) This is a general problem. I debugged a little and it seems that between class_init and ves_icall_Type_GetFields_internal the generic class' fields are being inflated - at the end of class_init the return type of _N_constant_object is A`1[T] and in mono_field_get_object it is A`1[int]. It happens only for externally loaded generic classes. ---- Additional Comments From martin@ximian.com 2005-06-21 08:45:59 MST ---- Fixed in SVN (r46298). Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>mono svn 17.06.2005</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".