2010-04-25 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sat, 24 Apr 2010 23:48:06 +0000 (23:48 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 24 Apr 2010 23:48:06 +0000 (23:48 -0000)
* class.c (mono_class_create_from_typedef): Initialize class->nested_in after
calling setup_mono_type () since the nested parent could recursively reference
the nested class using generic constraints. Fixes #599469.

svn path=/trunk/mono/; revision=156052

mono/metadata/ChangeLog
mono/metadata/class.c

index 0e967ff9d706ae144edb4cc6e57988215ddde8b5..8a5f270d48f1cc7ada4b3cd7669896911ff99e7d 100644 (file)
@@ -1,3 +1,9 @@
+2010-04-25  Zoltan Varga  <vargaz@gmail.com>
+
+       * class.c (mono_class_create_from_typedef): Initialize class->nested_in after
+       calling setup_mono_type () since the nested parent could recursively reference
+       the nested class using generic constraints. Fixes #599469.
+
 2010-04-24  Mark Probst  <mark.probst@gmail.com>
 
        * sgen-gc.c, sgen-pinning.c, sgen-major-copying.c: Major collector
index a6c1a32d3a1fe44e96409c24971d0beacb3f78e8..fa47ec83b1a558c1a3c313d1f41468fa272ad8d9 100644 (file)
@@ -5042,7 +5042,15 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
                }
        }
 
-       /* do this early so it's available for interfaces in setup_mono_type () */
+       mono_class_setup_parent (class, parent);
+
+       /* uses ->valuetype, which is initialized by mono_class_setup_parent above */
+       mono_class_setup_mono_type (class);
+
+       /* 
+        * This might access class->byval_arg for recursion generated by generic constraints,
+        * so it has to come after setup_mono_type ().
+        */
        if ((nesting_tokeen = mono_metadata_nested_in_typedef (image, type_token))) {
                class->nested_in = mono_class_create_from_typedef (image, nesting_tokeen);
                if (!class->nested_in) {
@@ -5053,11 +5061,6 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
                }
        }
 
-       mono_class_setup_parent (class, parent);
-
-       /* uses ->valuetype, which is initialized by mono_class_setup_parent above */
-       mono_class_setup_mono_type (class);
-
        if ((class->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_UNICODE_CLASS)
                class->unicode = 1;