Skip to content

Debugger: Prevent Abort on Invalid Virtual Method #2115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: unity-main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mono/mini/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -6545,6 +6545,10 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
PRINT_DEBUG_MSG (1, "[%p] Error: Interface method invoked without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ());
return ERR_INVALID_ARGUMENT;
}
if (!mono_object_isinst(this_arg, m->klass)) {
PRINT_DEBUG_MSG (1, "[%p] Error: Interface method invoked on object that doesn't implement the interface.\n", (gpointer) (gsize) mono_native_thread_id_get ());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, should the message include more info like type and interface/and method name?

return ERR_INVALID_ARGUMENT;
}
m = mono_object_get_virtual_method_internal (this_arg, m);
/* Transform this to the format the rest of the code expects it to be */
if (m_class_is_valuetype (m->klass)) {
Expand All @@ -6556,6 +6560,10 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
PRINT_DEBUG_MSG (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag set without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ());
return ERR_INVALID_ARGUMENT;
}
if (!mono_object_isinst(this_arg, m->klass)) {
PRINT_DEBUG_MSG (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag on object that object that doesn't implement the method.\n", (gpointer) (gsize) mono_native_thread_id_get ());
return ERR_INVALID_ARGUMENT;
}
m = mono_object_get_virtual_method_internal (this_arg, m);
if (m_class_is_valuetype (m->klass)) {
this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass));
Expand Down