[Mono-bugs] [Bug 75479][Nor] Changed -
mono_class_from_mono_type()/mono_type_get_underlying_type()
and generics
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Tue Feb 14 08:27:23 EST 2006
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 lupus at ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=75479
--- shadow/75479 2005-12-08 13:35:30.000000000 -0500
+++ shadow/75479.tmp.3362 2006-02-14 08:27:22.000000000 -0500
@@ -4,20 +4,19 @@
OS: unknown
OS Details: amd64 pld linux
Status: NEW
Resolution:
Severity: Unknown
Priority: Normal
-Component: GC
+Component: misc
AssignedTo: lupus at ximian.com
ReportedBy: malekith at pld-linux.org
QAContact: mono-bugs at ximian.com
TargetMilestone: ---
URL:
-Cc:
-Summary: [GMCS] GC is confused by generic structs
+Summary: mono_class_from_mono_type()/mono_type_get_underlying_type() and generics
Description of Problem:
The following testcase:
#v+
@@ -242,6 +241,32 @@
------- Additional Comments From martin at ximian.com 2005-12-08 13:35 -------
Thanks a lot for wasting yet another afternoon on this. I checked
get_underlying_type() everywhere and it's correct everywhere.
Considering the amout on time already spent on this bug (3.5 days), I
have no other choice but close it as WONTFIX if it ever bounces back
to me.
+
+------- Additional Comments From lupus at ximian.com 2006-02-14 08:27 -------
+The issue exposed by the test case can be 'fixed' with this temporary
+patch:
+--- metadata/class.c (revision 56832)
++++ metadata/class.c (working copy)
+@@ -983,7 +984,7 @@
+
+ if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
+ ftype = mono_type_get_underlying_type (field->type);
+- if (MONO_TYPE_IS_REFERENCE (ftype) || IS_GC_REFERENCE (ftype) ||
+((MONO_TYPE_ISSTRUCT (ftype) && mono_class_has_references
+(mono_class_from_mono_type (ftype)))))
++ if (MONO_TYPE_IS_REFERENCE (ftype) || IS_GC_REFERENCE (ftype) ||
+((MONO_TYPE_ISSTRUCT (ftype) && mono_class_has_references
+(mono_class_from_mono_type (field->type)))))
+ class->has_references = TRUE;
+ }
+ }
+
+The problem here is that mono_type_get_underlying_type() will return
+a broken type pointer, at least in the case of an instantiated generic
+struct. The low-level type is MONO_TYPE_VALUETYPE, but the MonoClass*
+pointer in it points to the uninstantiated generic struct and not the
+correct instantiated one, so when mono_class_from_mono_type() is
+called on it it gets the wrong info.
More information about the mono-bugs
mailing list