Skip to content

[release/9.0-staging] [mono][interp] Fix execution of delegate invoke wrapper with interpreter #111700

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

Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jan 22, 2025

Backport of #111310 to release/9.0-staging

/cc @BrzVlad

Customer Impact

This issue was customer reported #110995. It impacts customers using reflection to obtain the value of a virtual property, on iOS. This reflection capability requires fallback to interpreter, where the app crash occurs in this scenario.

Regression

This is a regression introduced in .NET8. The runtime bug causing the crash was introduced in #83461, but it seems there might have been additional changes leading to the crash actually reproducing to customers.

Testing

The fix was verified on the customer provided sample application. CI testing confirmed that JIT/AOT paths haven't been impacted.

Risk

Low risk. This commit contains a change to the IL code of a specific delegate invoke wrapper. For the interpreter, the previous path was crashing every time, so this fix can only make things better. For the rest of the execution engines (jit/aot) the change represents a minimal refactoring that shouldn't have any side effects.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

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.
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

@srxqds
Copy link
Contributor

srxqds commented Feb 17, 2025

merge it?

@steveisok
Copy link
Member

/ba-g BA showing all known test errors.

@steveisok steveisok merged commit 881b4bd into release/9.0-staging Feb 21, 2025
90 of 95 checks passed
@steveisok steveisok deleted the backport/pr-111310-to-release/9.0-staging branch February 21, 2025 15:09
@MDThomsen
Copy link

MDThomsen commented Mar 13, 2025

@kotlarmilos @BrzVlad Hey, as was also written (but for 8.0.14) in #112008 (comment) I cannot see that this change is on the 9.0.3 release. Is this intentional?

@BrzVlad
Copy link
Member

BrzVlad commented Mar 13, 2025

@carlossanlop Do you have more info on this ?

@steveisok
Copy link
Member

This unfortunately got merged after the 9.0.3 window closed. It'll be in 9.0.4.

@MDThomsen
Copy link

@BrzVlad @steveisok Ah okay, that's unfortunate. Is that also the case for the 8.0.14 window? I.e. that it will come out with 8.0.15 instead?

@carlossanlop
Copy link
Contributor

Yes, same case for 8.0.15. All servicing branches have the same code complete date.

@srxqds
Copy link
Contributor

srxqds commented Mar 13, 2025

The efficiency is really too low, one and half month has passed and there is still no patch.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants