Skip to content

[release/8.0-staging] [mono][interp] Attempt to interpret m2n wrapper if it is not found in aot image#105477

Merged
ivanpovazan merged 2 commits intorelease/8.0-stagingfrom
backport/pr-100025-to-release/8.0-staging
Jul 29, 2024
Merged

[release/8.0-staging] [mono][interp] Attempt to interpret m2n wrapper if it is not found in aot image#105477
ivanpovazan merged 2 commits intorelease/8.0-stagingfrom
backport/pr-100025-to-release/8.0-staging

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Jul 25, 2024

Backport of #100025 to release/8.0-staging

/cc @BrzVlad

Customer Impact

  • Customer reported
  • Found internally

In an ios application, if the user chooses to enable interpreter and mix it with aot compiled code (by using the MtouchInterpreter property), the application will crash if we attempt to do a pinvoke call from a compiled assembly into a pinvoke declared in an interpreted image. This seems to be easily reproducible if System.Private.CoreLib.dll is interpreted and the rest of the code is aot-ed (even the ios template fails with this configuration).

Regression

  • Yes
  • No

Testing

Fix was tested on the provided repro project.

Risk

Low Risk. The fix represents a fallback for cases when we couldn't find a m2n wrapper, in which case we would have been always crashing before.

BrzVlad added 2 commits July 25, 2024 13:52
interp_create_method_pointer should only ever return a function pointer callable from compiled code.
… aot image

On ios with interpreter enabled it can happen to mark an assembly as aot and have the rest interpreted, including SPC.dll. If the aot code attempts to do an icall, for example Math.Ceiling defined in SPC.dll, it will fail to find the m2n wrapper, since SPC.dll is not aot-ed. We fix this by obtaining an interp entry thunk, in order to execute the wrapper in interp, if we can't find the aot version of wrapper.
@dotnet-policy-service
Copy link
Contributor

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

@ivanpovazan ivanpovazan added the Servicing-consider Issue for next servicing release review label Jul 25, 2024
@lambdageek lambdageek added this to the 8.0.x milestone Jul 25, 2024
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jul 25, 2024
@rbhanda rbhanda modified the milestones: 8.0.x, 8.0.9 Jul 25, 2024
@ivanpovazan
Copy link
Member

This PR also fixes: #105510

@ivanpovazan ivanpovazan merged commit 4c77671 into release/8.0-staging Jul 29, 2024
@jkotas jkotas deleted the backport/pr-100025-to-release/8.0-staging branch August 16, 2024 04:47
@github-actions github-actions bot locked and limited conversation to collaborators Sep 15, 2024
@rbhanda rbhanda modified the milestones: 8.0.9, 8.0.10 Oct 7, 2024
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.

4 participants