Merge pull request #2346 from xmcclure/proxy-load-fail
authorAndi McClure <andi.mcclure@xamarin.com>
Tue, 15 Dec 2015 21:39:09 +0000 (16:39 -0500)
committerAndi McClure <andi.mcclure@xamarin.com>
Tue, 15 Dec 2015 21:39:09 +0000 (16:39 -0500)
Let GetTransparentProxy fail clean on load error (bug 36848)

1  2 
mono/metadata/icall.c
mono/tests/Makefile.am

diff --combined mono/metadata/icall.c
index eaecf5b2027da4795c132c2f3554dcd9f7fa986b,817f321be9d72ae84f40a7c64bd14e48a5334a6f..93433b6d9b9292bde5389d4be5872c3a65d2e714
@@@ -6,11 -6,10 +6,11 @@@
   *   Paolo Molaro (lupus@ximian.com)
   *     Patrik Torstensson (patrik.torstensson@labs2.com)
   *   Marek Safar (marek.safar@gmail.com)
 + *   Aleksey Kliger (aleksey@xamarin.com)
   *
   * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
   * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
 - * Copyright 2011-2014 Xamarin Inc (http://www.xamarin.com).
 + * Copyright 2011-2015 Xamarin Inc (http://www.xamarin.com).
   */
  
  #include <config.h>
@@@ -135,7 -134,7 +135,7 @@@ ves_icall_System_Array_GetValueImpl (Mo
        if (ac->element_class->valuetype)
                return mono_value_box (arr->obj.vtable->domain, ac->element_class, ea);
        else
 -              return *ea;
 +              return (MonoObject *)*ea;
  }
  
  ICALL_EXPORT MonoObject *
@@@ -545,7 -544,7 +545,7 @@@ ves_icall_System_Array_CreateInstanceIm
  
        aklass = mono_bounded_array_class_get (klass, mono_array_length (lengths), bounded);
  
 -      sizes = alloca (aklass->rank * sizeof(intptr_t) * 2);
 +      sizes = (uintptr_t *)alloca (aklass->rank * sizeof(intptr_t) * 2);
        for (i = 0; i < aklass->rank; ++i) {
                sizes [i] = mono_array_get (lengths, guint32, i);
                if (bounds)
@@@ -593,7 -592,7 +593,7 @@@ ves_icall_System_Array_CreateInstanceIm
  
        aklass = mono_bounded_array_class_get (klass, mono_array_length (lengths), bounded);
  
 -      sizes = alloca (aklass->rank * sizeof(intptr_t) * 2);
 +      sizes = (uintptr_t *)alloca (aklass->rank * sizeof(intptr_t) * 2);
        for (i = 0; i < aklass->rank; ++i) {
                sizes [i] = mono_array_get (lengths, guint64, i);
                if (bounds)
@@@ -771,7 -770,7 +771,7 @@@ ves_icall_System_Array_SetGenericValueI
  
        if (MONO_TYPE_IS_REFERENCE (&ec->byval_arg)) {
                g_assert (esize == sizeof (gpointer));
 -              mono_gc_wbarrier_generic_store (ea, *(gpointer*)value);
 +              mono_gc_wbarrier_generic_store (ea, *(MonoObject **)value);
        } else {
                g_assert (ec->inited);
                g_assert (esize == mono_class_value_size (ec, NULL));
@@@ -1159,10 -1158,10 +1159,10 @@@ ves_icall_ModuleBuilder_RegisterToken (
  ICALL_EXPORT MonoObject*
  ves_icall_ModuleBuilder_GetRegisteredToken (MonoReflectionModuleBuilder *mb, guint32 token)
  {
 -      gpointer obj;
 +      MonoObject *obj;
  
        mono_loader_lock ();
 -      obj = mono_g_hash_table_lookup (mb->dynamic_image->tokens, GUINT_TO_POINTER (token));
 +      obj = (MonoObject *)mono_g_hash_table_lookup (mb->dynamic_image->tokens, GUINT_TO_POINTER (token));
        mono_loader_unlock ();
  
        return obj;
  static gboolean
  get_caller (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
  {
 -      MonoMethod **dest = data;
 +      MonoMethod **dest = (MonoMethod **)data;
  
        /* skip unmanaged frames */
        if (!managed)
  static gboolean
  get_executing (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
  {
 -      MonoMethod **dest = data;
 +      MonoMethod **dest = (MonoMethod **)data;
  
        /* skip unmanaged frames */
        if (!managed)
  static gboolean
  get_caller_no_reflection (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
  {
 -      MonoMethod **dest = data;
 +      MonoMethod **dest = (MonoMethod **)data;
  
        /* skip unmanaged frames */
        if (!managed)
@@@ -1781,9 -1780,9 +1781,9 @@@ ves_icall_MonoField_SetValueInternal (M
                                 */
                                nullable = mono_object_new (mono_domain_get (), nklass);
  
 -                              mono_nullable_init (mono_object_unbox (nullable), value, nklass);
 +                              mono_nullable_init ((guint8 *)mono_object_unbox (nullable), value, nklass);
  
 -                              v = mono_object_unbox (nullable);
 +                              v = (gchar *)mono_object_unbox (nullable);
                        }
                        else 
                                if (gclass->container_class->valuetype && (v != NULL))
@@@ -2031,8 -2030,8 +2031,8 @@@ typedef struct 
  static void
  fill_iface_array (gpointer key, gpointer value, gpointer user_data)
  {
 -      FillIfaceArrayData *data = user_data;
 -      MonoClass *ic = key;
 +      FillIfaceArrayData *data = (FillIfaceArrayData *)user_data;
 +      MonoClass *ic = (MonoClass *)key;
        MonoType *ret = &ic->byval_arg, *inflated = NULL;
  
        if (!mono_error_ok (data->error))
@@@ -2374,7 -2373,7 +2374,7 @@@ ves_icall_Type_GetGenericTypeDefinition
                tb = mono_class_get_ref_info (generic_class);
  
                if (generic_class->wastypebuilder && tb)
 -                      return tb;
 +                      return (MonoReflectionType *)tb;
                else
                        return mono_type_get_object (mono_object_domain (type), &generic_class->byval_arg);
        }
@@@ -2395,7 -2394,7 +2395,7 @@@ ves_icall_Type_MakeGenericType (MonoRef
        types = g_new0 (MonoType *, count);
  
        for (i = 0; i < count; i++) {
 -              MonoReflectionType *t = mono_array_get (type_array, gpointer, i);
 +              MonoReflectionType *t = (MonoReflectionType *)mono_array_get (type_array, gpointer, i);
                types [i] = t->type;
        }
  
@@@ -2446,7 -2445,7 +2446,7 @@@ ves_icall_Type_GetGenericParameterAttri
  {
        g_assert (IS_MONOTYPE (type));
        g_assert (is_generic_parameter (type->type));
 -      return mono_generic_param_info (type->type->data.generic_param)->flags;
 +      return (GenericParameterAttributes)mono_generic_param_info (type->type->data.generic_param)->flags;
  }
  
  ICALL_EXPORT MonoArray *
@@@ -2563,7 -2562,7 +2563,7 @@@ ves_icall_MonoMethod_GetPInvoke (MonoRe
  
        if (image_is_dynamic (image)) {
                MonoReflectionMethodAux *method_aux = 
 -                      g_hash_table_lookup (((MonoDynamicImage*)image)->method_aux_hash, method->method);
 +                      (MonoReflectionMethodAux *)g_hash_table_lookup (((MonoDynamicImage*)image)->method_aux_hash, method->method);
                if (method_aux) {
                        import = method_aux->dllentry;
                        scope = method_aux->dll;
@@@ -2618,7 -2617,7 +2618,7 @@@ ves_icall_MonoMethod_GetGenericMethodDe
                 * the dynamic case as well ?
                 */
                mono_image_lock ((MonoImage*)image);
 -              res = mono_g_hash_table_lookup (image->generic_def_objects, imethod);
 +              res = (MonoReflectionMethod *)mono_g_hash_table_lookup (image->generic_def_objects, imethod);
                mono_image_unlock ((MonoImage*)image);
  
                if (res)
@@@ -2765,7 -2764,7 +2765,7 @@@ ves_icall_InternalInvoke (MonoReflectio
                uintptr_t *lengths;
                intptr_t *lower_bounds;
                pcount = mono_array_length (params);
 -              lengths = alloca (sizeof (uintptr_t) * pcount);
 +              lengths = (uintptr_t *)alloca (sizeof (uintptr_t) * pcount);
                /* Note: the synthetized array .ctors have int32 as argument type */
                for (i = 0; i < pcount; ++i)
                        lengths [i] = *(int32_t*) ((char*)mono_array_get (params, gpointer, i) + sizeof (MonoObject));
                } else {
                        g_assert (pcount == (m->klass->rank * 2));
                        /* The arguments are lower-bound-length pairs */
 -                      lower_bounds = g_alloca (sizeof (intptr_t) * pcount);
 +                      lower_bounds = (intptr_t *)g_alloca (sizeof (intptr_t) * pcount);
  
                        for (i = 0; i < pcount / 2; ++i) {
                                lower_bounds [i] = *(int32_t*) ((char*)mono_array_get (params, gpointer, (i * 2)) + sizeof (MonoObject));
@@@ -2836,7 -2835,7 +2836,7 @@@ ves_icall_InternalExecute (MonoReflecti
                                        if (field_klass->valuetype)
                                                result = mono_value_box (domain, field_klass, (char *)this_arg + field->offset);
                                        else 
 -                                              result = *((gpointer *)((char *)this_arg + field->offset));
 +                                              result = (MonoObject *)*((gpointer *)((char *)this_arg + field->offset));
                                
                                        out_args = mono_array_new (domain, mono_defaults.object_class, 1);
                                        mono_gc_wbarrier_generic_store (outArgs, (MonoObject*) out_args);
                                MonoClassField* field = mono_class_get_field_from_name (k, str);
                                if (field) {
                                        MonoClass *field_klass =  mono_class_from_mono_type (field->type);
 -                                      MonoObject *val = mono_array_get (params, gpointer, 2);
 +                                      MonoObject *val = (MonoObject *)mono_array_get (params, gpointer, 2);
  
                                        if (field_klass->valuetype) {
                                                size = mono_type_size (field->type, &align);
@@@ -2967,19 -2966,19 +2967,19 @@@ write_enum_value (char *mem, int type, 
        }
        case MONO_TYPE_U2:
        case MONO_TYPE_I2: {
 -              guint16 *p = (void*)mem;
 +              guint16 *p = (guint16 *)mem;
                *p = value;
                break;
        }
        case MONO_TYPE_U4:
        case MONO_TYPE_I4: {
 -              guint32 *p = (void*)mem;
 +              guint32 *p = (guint32 *)mem;
                *p = value;
                break;
        }
        case MONO_TYPE_U8:
        case MONO_TYPE_I8: {
 -              guint64 *p = (void*)mem;
 +              guint64 *p = (guint64 *)mem;
                *p = value;
                break;
        }
@@@ -3479,7 -3478,7 +3479,7 @@@ ves_icall_Type_GetMethodsByName (MonoRe
        res = mono_array_new_specific (array_vtable, method_array->len);
  
        for (i = 0; i < method_array->len; ++i) {
 -              MonoMethod *method = g_ptr_array_index (method_array, i);
 +              MonoMethod *method = (MonoMethod *)g_ptr_array_index (method_array, i);
                mono_array_setref (res, i, mono_method_get_object (domain, method, refklass));
        }
  
@@@ -5038,7 -5037,7 +5038,7 @@@ ves_icall_System_Reflection_Assembly_Ge
  
        ex_count = 0;
        for (i = 0; i < len; i++) {
 -              MonoReflectionType *t = mono_array_get (res, gpointer, i);
 +              MonoReflectionType *t = (MonoReflectionType *)mono_array_get (res, gpointer, i);
                MonoClass *klass;
  
                if (t) {
                exl = mono_array_new (domain, mono_defaults.exception_class, length);
                /* Types for which mono_class_get_checked () succeeded */
                for (i = 0, tmp = list; tmp; i++, tmp = tmp->next) {
 -                      MonoException *exc = mono_class_get_exception_for_failure (tmp->data);
 +                      MonoException *exc = mono_class_get_exception_for_failure ((MonoClass *)tmp->data);
                        mono_array_setref (exl, i, exc);
                }
                /* Types for which it don't */
@@@ -5257,12 -5256,12 +5257,12 @@@ ves_icall_System_Reflection_Module_Reso
  
        if (image_is_dynamic (image)) {
                if ((table == MONO_TABLE_TYPEDEF) || (table == MONO_TABLE_TYPEREF)) {
 -                      klass = mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
 +                      klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
                        return klass ? &klass->byval_arg : NULL;
                }
  
                init_generic_context_from_args (&context, type_args, method_args);
 -              klass = mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context);
 +              klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context);
                return klass ? &klass->byval_arg : NULL;
        }
  
@@@ -5303,7 -5302,7 +5303,7 @@@ ves_icall_System_Reflection_Module_Reso
  
        if (image_is_dynamic (image)) {
                if (table == MONO_TABLE_METHOD)
 -                      return mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
 +                      return (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
  
                if ((table == MONO_TABLE_MEMBERREF) && !(mono_memberref_is_method (image, token))) {
                        *resolve_error = ResolveTokenError_BadTable;
                }
  
                init_generic_context_from_args (&context, type_args, method_args);
 -              return mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context);
 +              return (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context);
        }
  
        if ((index <= 0) || (index > image->tables [table].rows)) {
@@@ -5344,7 -5343,7 +5344,7 @@@ ves_icall_System_Reflection_Module_Reso
        }
  
        if (image_is_dynamic (image))
 -              return mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
 +              return (MonoString *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
  
        if ((index <= 0) || (index >= image->heap_us.size)) {
                *error = ResolveTokenError_OutOfRange;
@@@ -5376,7 -5375,7 +5376,7 @@@ ves_icall_System_Reflection_Module_Reso
  
        if (image_is_dynamic (image)) {
                if (table == MONO_TABLE_FIELD)
 -                      return mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
 +                      return (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL);
  
                if (mono_memberref_is_method (image, token)) {
                        *resolve_error = ResolveTokenError_BadTable;
                }
  
                init_generic_context_from_args (&context, type_args, method_args);
 -              return mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context);
 +              return (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context);
        }
  
        if ((index <= 0) || (index > image->tables [table].rows)) {
@@@ -5783,10 -5782,15 +5783,15 @@@ ves_icall_Remoting_RealProxy_GetTranspa
        type = ((MonoReflectionType *)rp->class_to_proxy)->type;
        klass = mono_class_from_mono_type (type);
  
+       // mono_remote_class_vtable cannot handle errors well, so force any loading error to occur early
+       mono_class_setup_vtable (klass);
+       if (klass->exception_type)
+               mono_raise_exception (mono_class_get_exception_for_failure (klass));
        tp->custom_type_info = (mono_object_isinst (this_obj, mono_defaults.iremotingtypeinfo_class) != NULL);
        tp->remote_class = mono_remote_class (domain, class_name, klass);
  
 -      res->vtable = mono_remote_class_vtable (domain, tp->remote_class, rp);
 +      res->vtable = (MonoVTable *)mono_remote_class_vtable (domain, tp->remote_class, rp);
        return res;
  }
  
@@@ -6121,7 -6125,7 +6126,7 @@@ ves_icall_System_Environment_GetLogical
                if (size > initial_size) {
                        if (ptr != buf)
                                g_free (ptr);
 -                      ptr = g_malloc0 ((size + 1) * sizeof (gunichar2));
 +                      ptr = (gunichar2 *)g_malloc0 ((size + 1) * sizeof (gunichar2));
                        initial_size = size;
                        size++;
                }
@@@ -6488,7 -6492,7 +6493,7 @@@ get_bundled_app_config (void
                return NULL;
  
        len = config_file_path_length - config_ext_length;
 -      module = g_malloc0 (len + 1);
 +      module = (gchar *)g_malloc0 (len + 1);
        memcpy (module, config_file_path, len);
        // Get the config file from the module name
        app_config = mono_config_string_for_assembly_file (module);
@@@ -6552,7 -6556,7 +6557,7 @@@ ves_icall_get_resources_ptr (MonoReflec
        *result = NULL;
        *size = 0;
        image = assembly->assembly->image;
 -      entry = mono_image_lookup_resource (image, MONO_PE_RESOURCE_ID_ASPNET_STRING, 0, NULL);
 +      entry = (MonoPEResourceDataEntry *)mono_image_lookup_resource (image, MONO_PE_RESOURCE_ID_ASPNET_STRING, 0, NULL);
        if (!entry)
                return FALSE;
  
@@@ -6620,7 -6624,6 +6625,7 @@@ ICALL_EXPORT MonoReflectionMethod 
  ves_icall_MonoMethod_get_base_method (MonoReflectionMethod *m, gboolean definition)
  {
        MonoClass *klass, *parent;
 +      MonoGenericContext *generic_inst = NULL;
        MonoMethod *method = m->method;
        MonoMethod *result = NULL;
        int slot;
                return m;
  
        klass = method->klass;
 -      if (klass->generic_class)
 +      if (klass->generic_class) {
 +              generic_inst = mono_class_get_context (klass);
                klass = klass->generic_class->container_class;
 +      }
  
        if (definition) {
                /* At the end of the loop, klass points to the eldest class that has this virtual function slot. */
                for (parent = klass->parent; parent != NULL; parent = parent->parent) {
 +                      /* on entry, klass is either a plain old non-generic class and generic_inst == NULL
 +                         or klass is the generic container class and generic_inst is the instantiation.
 +
 +                         when we go to the parent, if the parent is an open constructed type, we need to
 +                         replace the type parameters by the definitions from the generic_inst, and then take it
 +                         apart again into the klass and the generic_inst.
 +
 +                         For cases like this:
 +                         class C<T> : B<T, int> {
 +                             public override void Foo () { ... }
 +                         }
 +                         class B<U,V> : A<HashMap<U,V>> {
 +                             public override void Foo () { ... }
 +                         }
 +                         class A<X> {
 +                             public virtual void Foo () { ... }
 +                         }
 +
 +                         if at each iteration the parent isn't open, we can skip inflating it.  if at some
 +                         iteration the parent isn't generic (after possible inflation), we set generic_inst to
 +                         NULL;
 +                      */
 +                      MonoGenericContext *parent_inst = NULL;
 +                      if (mono_class_is_open_constructed_type (mono_class_get_type (parent))) {
 +                              MonoError error;
 +                              parent = mono_class_inflate_generic_class_checked (parent, generic_inst, &error);
 +                              mono_error_raise_exception(&error);
 +                      }
 +                      if (parent->generic_class) {
 +                              parent_inst = mono_class_get_context (parent);
 +                              parent = parent->generic_class->container_class;
 +                      }
 +
                        mono_class_setup_vtable (parent);
                        if (parent->vtable_size <= slot)
                                break;
                        klass = parent;
 +                      generic_inst = parent_inst;
                }
        } else {
                klass = klass->parent;
                if (!klass)
                        return m;
 +              if (mono_class_is_open_constructed_type (mono_class_get_type (klass))) {
 +                      MonoError error;
 +                      klass = mono_class_inflate_generic_class_checked (klass, generic_inst, &error);
 +                      mono_error_raise_exception(&error);
 +
 +                      generic_inst = NULL;
 +              }
 +              if (klass->generic_class) {
 +                      generic_inst = mono_class_get_context (klass);
 +                      klass = klass->generic_class->container_class;
 +              }
 +
 +      }
 +
 +      if (generic_inst) {
 +              MonoError error;
 +              klass = mono_class_inflate_generic_class_checked (klass, generic_inst, &error);
 +              mono_error_raise_exception(&error);
        }
  
        if (klass == method->klass)
@@@ -6854,7 -6803,7 +6859,7 @@@ ICALL_EXPORT MonoObject
  mono_TypedReference_ToObject (MonoTypedRef* tref)
  {
        if (MONO_TYPE_IS_REFERENCE (tref->type)) {
 -              MonoObject** objp = tref->value;
 +              MonoObject** objp = (MonoObject **)tref->value;
                return *objp;
        }
  
@@@ -7395,7 -7344,7 +7400,7 @@@ compare_method_imap (const void *key, c
  static gpointer
  find_method_icall (const IcallTypeDesc *imap, const char *name)
  {
 -      const guint16 *nameslot = mono_binary_search (name, icall_names_idx + imap->first_icall, icall_desc_num_icalls (imap), sizeof (icall_names_idx [0]), compare_method_imap);
 +      const guint16 *nameslot = (const guint16 *)mono_binary_search (name, icall_names_idx + imap->first_icall, icall_desc_num_icalls (imap), sizeof (icall_names_idx [0]), compare_method_imap);
        if (!nameslot)
                return NULL;
        return (gpointer)icall_functions [(nameslot - &icall_names_idx [0])];
@@@ -7411,7 -7360,7 +7416,7 @@@ compare_class_imap (const void *key, co
  static const IcallTypeDesc*
  find_class_icalls (const char *name)
  {
 -      const guint16 *nameslot = mono_binary_search (name, icall_type_names_idx, Icall_type_num, sizeof (icall_type_names_idx [0]), compare_class_imap);
 +      const guint16 *nameslot = (const guint16 *)mono_binary_search (name, icall_type_names_idx, Icall_type_num, sizeof (icall_type_names_idx [0]), compare_class_imap);
        if (!nameslot)
                return NULL;
        return &icall_type_descs [nameslot - &icall_type_names_idx [0]];
@@@ -7670,48 -7619,48 +7675,48 @@@ mono_lookup_icall_symbol (MonoMethod *m
  }
  
  static MonoType*
 -type_from_typename (char *typename)
 +type_from_typename (char *type_name)
  {
        MonoClass *klass = NULL;        /* assignment to shut GCC warning up */
  
 -      if (!strcmp (typename, "int"))
 +      if (!strcmp (type_name, "int"))
                klass = mono_defaults.int_class;
 -      else if (!strcmp (typename, "ptr"))
 +      else if (!strcmp (type_name, "ptr"))
                klass = mono_defaults.int_class;
 -      else if (!strcmp (typename, "void"))
 +      else if (!strcmp (type_name, "void"))
                klass = mono_defaults.void_class;
 -      else if (!strcmp (typename, "int32"))
 +      else if (!strcmp (type_name, "int32"))
                klass = mono_defaults.int32_class;
 -      else if (!strcmp (typename, "uint32"))
 +      else if (!strcmp (type_name, "uint32"))
                klass = mono_defaults.uint32_class;
 -      else if (!strcmp (typename, "int8"))
 +      else if (!strcmp (type_name, "int8"))
                klass = mono_defaults.sbyte_class;
 -      else if (!strcmp (typename, "uint8"))
 +      else if (!strcmp (type_name, "uint8"))
                klass = mono_defaults.byte_class;
 -      else if (!strcmp (typename, "int16"))
 +      else if (!strcmp (type_name, "int16"))
                klass = mono_defaults.int16_class;
 -      else if (!strcmp (typename, "uint16"))
 +      else if (!strcmp (type_name, "uint16"))
                klass = mono_defaults.uint16_class;
 -      else if (!strcmp (typename, "long"))
 +      else if (!strcmp (type_name, "long"))
                klass = mono_defaults.int64_class;
 -      else if (!strcmp (typename, "ulong"))
 +      else if (!strcmp (type_name, "ulong"))
                klass = mono_defaults.uint64_class;
 -      else if (!strcmp (typename, "float"))
 +      else if (!strcmp (type_name, "float"))
                klass = mono_defaults.single_class;
 -      else if (!strcmp (typename, "double"))
 +      else if (!strcmp (type_name, "double"))
                klass = mono_defaults.double_class;
 -      else if (!strcmp (typename, "object"))
 +      else if (!strcmp (type_name, "object"))
                klass = mono_defaults.object_class;
 -      else if (!strcmp (typename, "obj"))
 +      else if (!strcmp (type_name, "obj"))
                klass = mono_defaults.object_class;
 -      else if (!strcmp (typename, "string"))
 +      else if (!strcmp (type_name, "string"))
                klass = mono_defaults.string_class;
 -      else if (!strcmp (typename, "bool"))
 +      else if (!strcmp (type_name, "bool"))
                klass = mono_defaults.boolean_class;
 -      else if (!strcmp (typename, "boolean"))
 +      else if (!strcmp (type_name, "boolean"))
                klass = mono_defaults.boolean_class;
        else {
 -              g_error ("%s", typename);
 +              g_error ("%s", type_name);
                g_assert_not_reached ();
        }
        return &klass->byval_arg;
@@@ -7730,7 -7679,7 +7735,7 @@@ mono_create_icall_signature (const cha
        MonoImage *corlib = mono_defaults.corlib;
  
        mono_image_lock (corlib);
 -      res = g_hash_table_lookup (corlib->helper_signatures, sigstr);
 +      res = (MonoMethodSignature *)g_hash_table_lookup (corlib->helper_signatures, sigstr);
        mono_image_unlock (corlib);
  
        if (res)
        g_strfreev (parts);
  
        mono_image_lock (corlib);
 -      res2 = g_hash_table_lookup (corlib->helper_signatures, sigstr);
 +      res2 = (MonoMethodSignature *)g_hash_table_lookup (corlib->helper_signatures, sigstr);
        if (res2)
                res = res2; /*Value is allocated in the image pool*/
        else
@@@ -7781,7 -7730,7 +7786,7 @@@ mono_find_jit_icall_by_name (const cha
        g_assert (jit_icall_hash_name);
  
        mono_icall_lock ();
 -      info = g_hash_table_lookup (jit_icall_hash_name, name);
 +      info = (MonoJitICallInfo *)g_hash_table_lookup (jit_icall_hash_name, name);
        mono_icall_unlock ();
        return info;
  }
@@@ -7793,7 -7742,7 +7798,7 @@@ mono_find_jit_icall_by_addr (gconstpoin
        g_assert (jit_icall_hash_addr);
  
        mono_icall_lock ();
 -      info = g_hash_table_lookup (jit_icall_hash_addr, (gpointer)addr);
 +      info = (MonoJitICallInfo *)g_hash_table_lookup (jit_icall_hash_addr, (gpointer)addr);
        mono_icall_unlock ();
  
        return info;
@@@ -7823,7 -7772,7 +7828,7 @@@ mono_lookup_jit_icall_symbol (const cha
        const char *res = NULL;
  
        mono_icall_lock ();
 -      info = g_hash_table_lookup (jit_icall_hash_name, name);
 +      info = (MonoJitICallInfo *)g_hash_table_lookup (jit_icall_hash_name, name);
        if (info)
                res = info->c_symbol;
        mono_icall_unlock ();
diff --combined mono/tests/Makefile.am
index f784c41bfdcb5254988f24156497a91607202c97,132af7369c0482999eb778a85a6c04b271e4380c..1535dec49d884584e8319b269935bc31ba1c5086
@@@ -188,7 -188,6 +188,7 @@@ BASE_TEST_CS_SRC=          
        delegate10.cs           \
        delegate11.cs           \
        delegate12.cs           \
 +      delegate13.cs           \
        remoting1.cs            \
        remoting2.cs            \
        remoting3.cs            \
        bug-324535.cs   \
        modules.cs      \
        bug-81673.cs    \
+       bug-36848.cs    \
        bug-81691.cs    \
        bug-80307.cs    \
        bug-415577.cs   \
@@@ -1198,6 -1198,12 +1199,12 @@@ bug-81673.exe bug-81673-interface.dll: 
        $(MCS) -out:bug-81673.exe -r:bug-81673-interface.dll $(srcdir)/bug-81673.cs
        $(MCS) -define:WITH_STOP -target:library -out:bug-81673-interface.dll $(srcdir)/bug-81673-interface.cs
  
+ EXTRA_DIST += bug-36848-a.cs.cs
+ bug-36848.exe bug-36848-a.dll: $(srcdir)/bug-36848.cs $(srcdir)/bug-36848-a.cs
+       $(MCS) -target:library -out:bug-36848-a.dll $(srcdir)/bug-36848-a.cs
+       $(MCS) -r:bug-36848-a.dll -out:bug-36848.exe $(srcdir)/bug-36848.cs
+       $(MCS) -target:library -out:bug-36848-a.dll $(srcdir)/bug-36848-a.cs /define:WITH_STOP
  EXTRA_DIST += bug-81691-a.cs bug-81691-b.cs
  bug-81691.exe bug-81691-b.dll: $(srcdir)/bug-81691.cs $(srcdir)/bug-81691-a.cs $(srcdir)/bug-81691-b.cs
        $(MCS) -target:library -out:bug-81691-a.dll $(srcdir)/bug-81691-a.cs