Merge pull request #2716 from BrzVlad/fix-tramp-jinfo
authorVlad Brezae <brezaevlad@gmail.com>
Thu, 3 Mar 2016 14:56:47 +0000 (21:56 +0700)
committerVlad Brezae <brezaevlad@gmail.com>
Thu, 3 Mar 2016 14:56:47 +0000 (21:56 +0700)
[aot] Set null uw_info for tramps without unwind info

1  2 
mono/mini/aot-runtime.c

diff --combined mono/mini/aot-runtime.c
index f0bc05c4e20adf58c46612c448af4ecfd12cea62,6660cac4832afb17a9a7f3adeb9f05313e1ead26..fe1dabc59285bbe99103336474297b25184ee148
@@@ -462,7 -462,6 +462,7 @@@ decode_klass_ref (MonoAotModule *module
                g_assert (mono_error_ok (&error));
                break;
        case MONO_AOT_TYPEREF_GINST: {
 +              MonoError error;
                MonoClass *gclass;
                MonoGenericContext ctx;
                MonoType *type;
                ctx.class_inst = decode_generic_inst (module, p, &p);
                if (!ctx.class_inst)
                        return NULL;
 -              type = mono_class_inflate_generic_type (&gclass->byval_arg, &ctx);
 +              type = mono_class_inflate_generic_type_checked (&gclass->byval_arg, &ctx, &error);
 +              mono_error_assert_ok (&error); /* FIXME don't swallow the error */
                klass = mono_class_from_mono_type (type);
                mono_metadata_free_type (type);
                break;
@@@ -662,7 -660,6 +662,7 @@@ decode_type (MonoAotModule *module, gui
                t->data.type = decode_type (module, p, &p);
                break;
        case MONO_TYPE_GENERICINST: {
 +              MonoError error;
                MonoClass *gclass;
                MonoGenericContext ctx;
                MonoType *type;
                ctx.class_inst = decode_generic_inst (module, p, &p);
                if (!ctx.class_inst)
                        return NULL;
 -              type = mono_class_inflate_generic_type (&gclass->byval_arg, &ctx);
 +              type = mono_class_inflate_generic_type_checked (&gclass->byval_arg, &ctx, &error);
 +              mono_error_assert_ok (&error); /* FIXME don't swallow the error */
 +
                klass = mono_class_from_mono_type (type);
                t->data.generic_class = klass->generic_class;
                break;
@@@ -4134,13 -4129,10 +4134,13 @@@ init_llvm_method (MonoAotModule *amodul
                        if (!got [got_slots [pindex]] || ji->type == MONO_PATCH_INFO_SFLDA) {
                                /* In llvm-only made, we might encounter shared methods */
                                if (mono_llvm_only && ji->type == MONO_PATCH_INFO_METHOD && mono_method_check_context_used (ji->data.method)) {
 -                                      MonoError error;
 -
                                        g_assert (context);
 -                                      ji->data.method = mono_class_inflate_generic_method_checked (ji->data.method, context, &error);
 +                                      ji->data.method = mono_class_inflate_generic_method_checked (ji->data.method, context, error);
 +                                      if (!mono_error_ok (error)) {
 +                                              g_free (got_slots);
 +                                              mono_mempool_destroy (mp);
 +                                              return FALSE;
 +                                      }
                                }
                                /* This cannot be resolved in mono_resolve_patch_target () */
                                if (ji->type == MONO_PATCH_INFO_AOT_JIT_INFO) {
  
        gboolean inited_ok = TRUE;
        if (init_class)
 -              inited_ok = mono_runtime_class_init_full (mono_class_vtable (domain, init_class), &error);
 +              inited_ok = mono_runtime_class_init_full (mono_class_vtable (domain, init_class), error);
        else if (from_plt && klass && !klass->generic_container)
 -              inited_ok = mono_runtime_class_init_full (mono_class_vtable (domain, klass), &error);
 +              inited_ok = mono_runtime_class_init_full (mono_class_vtable (domain, klass), error);
        if (!inited_ok)
 -              mono_error_raise_exception (&error); /* FIXME don't raise here */
 +              return FALSE;
  
        return TRUE;
  
@@@ -4896,8 -4888,9 +4896,9 @@@ load_function_full (MonoAotModule *amod
                tinfo = g_new0 (MonoTrampInfo, 1);
                tinfo->code = (guint8 *)code;
                tinfo->code_size = code_size;
-               tinfo->uw_info = uw_info;
                tinfo->uw_info_len = uw_info_len;
+               if (uw_info_len)
+                       tinfo->uw_info = uw_info;
  
                *out_tinfo = tinfo;
        }
@@@ -5062,8 -5055,11 +5063,11 @@@ read_unwind_info (MonoAotModule *amodul
        uw_info = amodule->unwind_info + uw_offset;
        uw_info_len = decode_value (uw_info, &uw_info);
  
-       info->uw_info = uw_info;
        info->uw_info_len = uw_info_len;
+       if (uw_info_len)
+               info->uw_info = uw_info;
+       else
+               info->uw_info = NULL;
  
        /* If successful return the address of the following data */
        return (guint32*)symbol_addr + 1;