-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[mono][interp] Keep delegate alive during invocation #100832
Conversation
When invoking a delegate, we were overwritting the stack slot containing the delegate object reference. In the case of invoking a delegate for a dynamic method, we were running into issues when the delegate object is collected while the method is executed because the method code is also discarded.
Tagging subscribers to this area: @BrzVlad, @kotlarmilos |
Is it bad that for long-running method bodies, we never null out the ref_slot_offset after a call? It potentially means we leak a delegate instance for a while, but I can't imagine a realistic scenario where that would cause a program to meaningfully degrade just from one delegate surviving GC during a loop. Could break synthetic GC tests maybe. |
@@ -4164,6 +4164,9 @@ mono_interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClause | |||
} | |||
cmethod = del_imethod; | |||
if (!is_multicast) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does multicast not need this deathgrip var because multicast invokes are done by a helper method that has 'this' on the stack?
When invoking a delegate, we were overwritting the stack slot containing the delegate object reference. In the case of invoking a delegate for a dynamic method, we were running into issues when the delegate object is collected while the method is executed because the method code is also discarded.
When invoking a delegate, we were overwritting the stack slot containing the delegate object reference. In the case of invoking a delegate for a dynamic method, we were running into issues when the delegate object is collected while the method is executed because the method code is also discarded.