Skip to content

Commit f763f4a

Browse files
author
brianradunity
authored
Merge pull request #1002 from Unity-Technologies/debugger-invoke-generic-check
Add check for a generic method when invoking in debugger
2 parents 16681b9 + eb5815c commit f763f4a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

mcs/class/Mono.Debugger.Soft/Test/dtest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4396,5 +4396,17 @@ public void Pointer_GetValue () {
43964396
AssertValue (3.0, f);
43974397

43984398
}
4399+
4400+
[Test]
4401+
public void InvokeGenericMethod () {
4402+
Event e = run_until ("bp1");
4403+
StackFrame frame = e.Thread.GetFrames()[0];
4404+
TypeMirror t = frame.Method.DeclaringType;
4405+
MethodMirror m;
4406+
m = t.GetMethod ("generic_method");
4407+
AssertThrows<ArgumentException> (delegate {
4408+
t.InvokeMethod (e.Thread, m, null);
4409+
});
4410+
}
43994411
} // class DebuggerTests
44004412
} // namespace

mono/mini/debugger-agent.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8181,7 +8181,11 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
81818181
this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass));
81828182
else
81838183
this_buf = (guint8 *)g_alloca (sizeof (MonoObject*));
8184-
if (m->klass->valuetype && (m->flags & METHOD_ATTRIBUTE_STATIC)) {
8184+
8185+
if (m->is_generic) {
8186+
DEBUG_PRINTF (1, "[%p] Error: Attemtping to invoke uninflated generic method %s.\n", (gpointer)(gsize)mono_native_thread_id_get (), mono_method_full_name (m, TRUE));
8187+
return ERR_INVALID_ARGUMENT;
8188+
} else if (m->klass->valuetype && (m->flags & METHOD_ATTRIBUTE_STATIC)) {
81858189
/* Should be null */
81868190
int type = decode_byte (p, &p, end);
81878191
if (type != VALUE_TYPE_ID_NULL) {

0 commit comments

Comments
 (0)