Skip to content

[wasm][coreclr] Fix call delegate with IL stubs#125138

Merged
radekdoulik merged 5 commits intodotnet:mainfrom
radekdoulik:clr-wasm-fix-call-delegate
Mar 9, 2026
Merged

[wasm][coreclr] Fix call delegate with IL stubs#125138
radekdoulik merged 5 commits intodotnet:mainfrom
radekdoulik:clr-wasm-fix-call-delegate

Conversation

@radekdoulik
Copy link
Member

Fix open virtual delegate dispatch crash in interpreter (#124221)

When invoking an open virtual delegate over an interface method, the interpreter's shuffle thunk path resolved the target MethodDesc but fell through to the fallback path if the method had no interpreter code yet. The fallback incorrectly passed the shuffle thunk entry point to NonVirtualEntry2MethodDesc, which on FEATURE_PORTABLE_ENTRYPOINTS treated it as a PortableEntryPoint, crashing with an IsValid() assert.

Fix: call DoPrestub to compile the resolved method before checking for interpreter code, matching the existing CALL_INTERP_METHOD logic. Extract duplicated EnsureInterpreterCode helper used by both paths.

Also remove resolved ActiveIssue attributes for issue 124221 from Runtime_70259, Runtime_79354, and GSDelegate tests.

Fix open virtual delegate dispatch crash in interpreter (dotnet#124221)

When invoking an open virtual delegate over an interface method, the
interpreter's shuffle thunk path resolved the target MethodDesc but
fell through to the fallback path if the method had no interpreter code
yet. The fallback incorrectly passed the shuffle thunk entry point to
NonVirtualEntry2MethodDesc, which on FEATURE_PORTABLE_ENTRYPOINTS
treated it as a PortableEntryPoint, crashing with an IsValid() assert.

Fix: call DoPrestub to compile the resolved method before checking for
interpreter code, matching the existing CALL_INTERP_METHOD logic.
Extract duplicated EnsureInterpreterCode helper used by both paths.

Also remove resolved ActiveIssue attributes for issue 124221 from
Runtime_70259, Runtime_79354, and GSDelegate tests.
@radekdoulik radekdoulik added this to the Future milestone Mar 3, 2026
Copilot AI review requested due to automatic review settings March 3, 2026 17:58
@radekdoulik radekdoulik requested a review from kg as a code owner March 3, 2026 17:58
@radekdoulik radekdoulik added arch-wasm WebAssembly architecture area-VM-coreclr labels Mar 3, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a WASM/CoreCLR interpreter crash when invoking open virtual delegates over interface methods by ensuring the resolved target MethodDesc is prestubbed (and interpreter code generated) before deciding whether to take the interpreter fast path vs a fallback path. Also re-enables previously skipped regression tests now that the underlying issue is addressed.

Changes:

  • Add EnsureInterpreterCode(...) helper to deduplicate and align prestub/interpreter-code setup logic across call paths.
  • Update the delegate shuffle-thunk optimization path and the general CALL_INTERP_METHOD path to use the shared helper.
  • Remove ActiveIssue skips for issue #124221 from relevant tests (Runtime_70259, Runtime_79354, GSDelegate).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/coreclr/vm/interpexec.cpp Ensures target methods are prestubbed before checking for interpreter code; refactors common logic into EnsureInterpreterCode.
src/tests/JIT/Regression/JitBlue/Runtime_79354/Runtime_79354.cs Removes ActiveIssue skip for #124221 (re-enables test on WASM).
src/tests/JIT/Regression/JitBlue/Runtime_70259/Runtime_70259.cs Removes ActiveIssue skip for #124221.
src/tests/JIT/Regression/JitBlue/Runtime_70259/Runtime_70259.il Removes TestLibrary extern and ActiveIssue metadata tied to #124221.
src/tests/JIT/Methodical/delegate/GSDelegate.cs Removes ActiveIssue skip for #124221 (re-enables test on WASM).

@dotnet-policy-service
Copy link
Contributor

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

Copilot AI review requested due to automatic review settings March 6, 2026 13:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Clarified comment regarding WASM code generation and native relinking.
And remove the comment and use assert
Copilot AI review requested due to automatic review settings March 8, 2026 21:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

@radekdoulik radekdoulik merged commit 2255eec into dotnet:main Mar 9, 2026
115 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants