Uh oh!
There was an error while loading. Please reload this page.
[clr-interp] Fix Swift error handling for marshaled P/Invokes in interpreter - #125177
Conversation
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
72a25d1 to
fb5fadbCompareThere was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/coreclr/vm/wasm/helpers.cpp:732
pContextMDis unused in the WASM implementation ofGetCookieForCalliSig, which can trigger-Wunused-parameter//WXbuild breaks. Either remove the parameter name (keep the type for signature compatibility) or explicitly mark it unused (e.g.,UNREFERENCED_PARAMETER(pContextMD)).
void* GetCookieForCalliSig(MetaSig metaSig, MethodDesc *pContextMD)
{
STANDARD_VM_CONTRACT;
void* thunk = ComputeCalliSigThunk(metaSig);
if (thunk == NULL)
{
PORTABILITY_ASSERT("GetCookieForCalliSig: unknown thunk signature");
You can also share your feedback on Copilot code review. Take the survey.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fb5fadb to
8c9b943CompareUh oh!
There was an error while loading. Please reload this page.
…ling for Swift on ARM64
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review. Take the survey.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…rpreter (#125177) ## Description When a Swift P/Invoke requires marshaling (e.g. ref SwiftError), the interpreter creates an IL stub with a calli to the native function. Previously, the P/Invoke MethodDesc had no interpreter code, so INTOP_CALL fell through to InvokeManagedMethod, creating an outer native transition via InterpreterStub. The inner calli created a second transition. The inner Load_SwiftError captured x21 correctly, but ExecuteInterpretedMethod could save/restore x21 as a callee-saved register, causing the outer epilog to read a stale value. Debug actually also had two native transitions but it just passed by coincidence because the unoptimized C compiler didn't use x21 as a scratch register, so the SwiftError value survived through ExecuteInterpretedMethod. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
When a Swift P/Invoke requires marshaling (e.g. ref SwiftError), the interpreter creates an IL stub with a calli to the native function. Previously, the P/Invoke MethodDesc had no interpreter code, so INTOP_CALL fell through to InvokeManagedMethod, creating an outer native transition via InterpreterStub. The inner calli created a second transition. The inner Load_SwiftError captured x21 correctly, but ExecuteInterpretedMethod could save/restore x21 as a callee-saved register, causing the outer epilog to read a stale value.
Debug actually also had two native transitions but it just passed by coincidence because the unoptimized C compiler didn't use x21 as a scratch register, so the SwiftError value survived through ExecuteInterpretedMethod.