Skip to content

Commit

Permalink
Sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kg committed Jul 19, 2024
1 parent a65f233 commit d5315b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/mono/mono/metadata/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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))) {
Expand Down

0 comments on commit d5315b4

Please sign in to comment.