Author: raja
Date: 2007-06-11 13:07:13 -0400 (Mon, 11 Jun 2007)
New Revision: 79194

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/loader.c
Log:
Fix assertion when disassembling Mono.C5.dll
* loader.c (method_from_methodspec): Avoid inflating a method
twice with the same context.  If the methodref is inflated, use
the declaring method instead.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-06-11 17:07:03 UTC (rev 79193)
+++ trunk/mono/mono/metadata/ChangeLog  2007-06-11 17:07:13 UTC (rev 79194)
@@ -1,5 +1,10 @@
 2007-06-11  Raja R Harinath  <[EMAIL PROTECTED]>
 
+       Fix assertion when disassembling Mono.C5.dll
+       * loader.c (method_from_methodspec): Avoid inflating a method
+       twice with the same context.  If the methodref is inflated, use
+       the declaring method instead.
+
        * class.c (mono_class_from_generic_parameter): Fix case similar to
        bug #81830 handled below, but for method containers.
 

Modified: trunk/mono/mono/metadata/loader.c
===================================================================
--- trunk/mono/mono/metadata/loader.c   2007-06-11 17:07:03 UTC (rev 79193)
+++ trunk/mono/mono/metadata/loader.c   2007-06-11 17:07:13 UTC (rev 79194)
@@ -823,6 +823,7 @@
 method_from_methodspec (MonoImage *image, MonoGenericContext *context, guint32 
idx)
 {
        MonoMethod *method, *inflated;
+       MonoClass *klass;
        MonoTableInfo *tables = image->tables;
        MonoGenericContext *new_context = NULL;
        MonoGenericMethod *gmethod;
@@ -875,19 +876,27 @@
 
        method = mono_get_inflated_method (method);
 
+       klass = method->klass;
+
+       /* FIXME: Is this invalid metadata?  Should we throw an exception 
instead?  */
+       g_assert (!klass->generic_container);
+
+       if (klass->generic_class) {
+               g_assert (method->is_inflated);
+               method = ((MonoMethodInflated *) method)->declaring;
+       }
+
        container = method->generic_container;
        g_assert (container);
 
        gmethod = g_new0 (MonoGenericMethod, 1);
-       if (method->klass->generic_class)
-               gmethod->class_inst = method->klass->generic_class->inst;
+       if (klass->generic_class)
+               gmethod->class_inst = klass->generic_class->inst;
        gmethod->container = container;
 
        new_context = g_new0 (MonoGenericContext, 1);
        new_context->gmethod = gmethod;
-       /* FIXME: Is this correct? */
-       if (container->parent)
-               new_context->class_inst = container->parent->context.class_inst;
+       new_context->class_inst = gmethod->class_inst;
 
        /*
         * When parsing the methodspec signature, we're in the old context 
again:
@@ -926,12 +935,10 @@
                return inflated;
        }
 
-       context = new_context;
-
        mono_stats.generics_metadata_size += sizeof (MonoGenericMethod) +
                sizeof (MonoGenericContext) + param_count * sizeof (MonoType);
 
-       inflated = mono_class_inflate_generic_method_full (method, 
method->klass, new_context);
+       inflated = mono_class_inflate_generic_method_full (method, klass, 
new_context);
        g_hash_table_insert (container->method_hash, gmethod, inflated);
 
        return inflated;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to