-
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] Fix execution of delegate invoke wrapper with interpreter #111310
Conversation
The wrapper was relatively recently changed to icall into mono_get_addr_compiled_method in order to obtain a native function pointer to call using calli. This is incorrect on interpreter where we expect an `InterpMethod*`. This commit adds a new opcode instead, that on jit it goes through the same icall path, while on interpeter in similarly computes the appropiate method to call. On a separate track, it might be useful to investigate whether the necessary delegate invoke wrapper should have been present in the aot image and not be executed with the interpreter in the first place.
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.
LGTM!
Do you want to add a test case in src/tests/JIT/Methodical/delegate/VirtualDelegate.cs
?
@kotlarmilos Unfortunately this scenario is not easily tested given this path is not hit in interp only. One would need a very specific aot/interp transition, that we currently don't have testing support for. |
@BrzVlad could you please start the backports of this for 9 and 8? |
/backport to release/8.0-staging |
/backport to release/9.0-staging |
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/12906960733 |
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/12906962891 |
@BrzVlad backporting to "release/8.0-staging" failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: [mono][interp] Fix execution of delegate invoke wrapper with interpreter
Using index info to reconstruct a base tree...
M src/mono/mono/metadata/marshal-lightweight.c
M src/mono/mono/mini/interp/interp.c
M src/mono/mono/mini/interp/mintops.def
M src/mono/mono/mini/interp/transform.c
M src/mono/mono/mini/method-to-ir.c
Falling back to patching base and 3-way merge...
Auto-merging src/mono/mono/mini/method-to-ir.c
Auto-merging src/mono/mono/mini/interp/transform.c
Auto-merging src/mono/mono/mini/interp/mintops.def
Auto-merging src/mono/mono/mini/interp/interp.c
CONFLICT (content): Merge conflict in src/mono/mono/mini/interp/interp.c
Auto-merging src/mono/mono/metadata/marshal-lightweight.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 [mono][interp] Fix execution of delegate invoke wrapper with interpreter
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
The wrapper was relatively recently changed to icall into mono_get_addr_compiled_method in order to obtain a native function pointer to call using calli. This is incorrect on interpreter where we expect an
InterpMethod*
. This commit adds a new opcode instead, that on jit it goes through the same icall path, while on interpeter in similarly computes the appropiate method to call.On a separate track, it might be useful to investigate whether the necessary delegate invoke wrapper should have been present in the aot image and not be executed with the interpreter in the first place.
Likely regressed after #83461.
Should fix #110995.