From d5315b4859b3e64593aacc5663eb397346a6f073 Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Thu, 18 Jul 2024 19:55:27 -0700 Subject: [PATCH] Sanity checks --- src/mono/mono/metadata/loader.c | 1 + src/mono/mono/mini/interp/interp.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/loader.c b/src/mono/mono/metadata/loader.c index 467fe0e668c07..921fe29e2743e 100644 --- a/src/mono/mono/metadata/loader.c +++ b/src/mono/mono/metadata/loader.c @@ -1303,6 +1303,7 @@ get_method_constrained (MonoImage *image, MonoMethod *method, MonoClass *constra g_assert (itf_slot >= 0); gboolean variant = FALSE; int itf_base = mono_class_interface_offset_with_variance (constrained_class, base_class, &variant); + g_assert (itf_base >= 0); vtable_slot = itf_slot + itf_base; } g_assert (vtable_slot >= 0); diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index 1e31ba4cdca65..4e16a84bf9751 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -647,6 +647,10 @@ get_virtual_method (InterpMethod *imethod, MonoVTable *vtable) virtual_method = mono_marshal_get_synchronized_wrapper (virtual_method); } + // Basic sanity check since a call might crash if we have the wrong method somehow + g_assert (m->signature->param_count == virtual_method->signature->param_count); + g_assert (m->signature->hasthis == virtual_method->signature->hasthis); + InterpMethod *virtual_imethod = mono_interp_get_imethod (virtual_method); return virtual_imethod; } @@ -7479,7 +7483,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; if (local_cmethod->is_generic || mono_class_is_gtd (local_cmethod->klass)) { MonoException *ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "InvalidOperationException", ""); THROW_EX (ex, ip); - } + } // FIXME push/pop LMF if (G_UNLIKELY (mono_method_has_unmanaged_callers_only_attribute (local_cmethod))) {