Skip to content

Commit a0411df

Browse files
[mono][interp] Resolve virtual method on delegates created by compiled code (dotnet#101290)
Creating a delegate would normally end up calling into the runtime via ves_icall_mono_delegate_ctor. However, jit/aot backand have a fastpath where the delegate is not fully initialized (relying on the delegate trampoline to resolve the actual method to be called when the delegate is first called). Interp delegate initialization therefore doesn't take place. If this is the case and the delegate method is virtual, we would need to resolve it based on the target object. Co-authored-by: Vlad Brezae <brezaevlad@gmail.com>
1 parent 9f4259e commit a0411df

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/mono/mono/mini/interp/interp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4016,6 +4016,8 @@ mono_interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClause
40164016
// Not created from interpreted code
40174017
g_assert (del->method);
40184018
del_imethod = mono_interp_get_imethod (del->method);
4019+
if (del->target && m_method_is_virtual (del->method))
4020+
del_imethod = get_virtual_method (del_imethod, del->target->vtable);
40194021
del->interp_method = del_imethod;
40204022
del->interp_invoke_impl = del_imethod;
40214023
} else {

0 commit comments

Comments
 (0)