Skip to content

[wasm][coreclr] Fix prestub of methods with IL helper stubs#124873

Open
radekdoulik wants to merge 3 commits intodotnet:mainfrom
radekdoulik:clr-wasm-prestub-il-helpers
Open

[wasm][coreclr] Fix prestub of methods with IL helper stubs#124873
radekdoulik wants to merge 3 commits intodotnet:mainfrom
radekdoulik:clr-wasm-prestub-il-helpers

Conversation

@radekdoulik
Copy link
Member

Fix #121955

@radekdoulik radekdoulik added this to the Future milestone Feb 25, 2026
@radekdoulik radekdoulik added the arch-wasm WebAssembly architecture label Feb 25, 2026
Copilot AI review requested due to automatic review settings February 25, 2026 21:44
@dotnet-policy-service
Copy link
Contributor

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

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

This PR fixes a WASM/CoreCLR interpreter prestub issue where methods implemented via managed IL helper stubs could end up publishing an entrypoint that maps to the helper MethodDesc, breaking MethodDesc lookups and access checks (manifesting as MethodAccessException, e.g. around delegate construction).

Changes:

  • Update MethodDesc::DoPrestub (FCall + managed-impl + portable entrypoints) to publish this method’s own PortableEntryPoint and attach interpreter data to it, instead of reusing the helper’s portable entrypoint.
  • Enable interpreter callsite access-check callouts on WASM by removing the #ifndef TARGET_WASM guard.

Reviewed changes

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

File Description
src/coreclr/vm/prestub.cpp Publishes the current method’s portable entrypoint and sets interpreter data for managed FCall helper-stub scenarios.
src/coreclr/interpreter/compiler.cpp Enables emitting callsite access-check callouts on WASM by removing a WASM-only compile-time exclusion.

@@ -2315,6 +2315,18 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
(void)helperMD->DoPrestub(NULL /* MethodTable */, CallerGCMode::Coop);
void* ilStubInterpData = helperMD->GetInterpreterCode();
SetInterpreterCode((InterpByteCodeStart*)ilStubInterpData);
Copy link
Member

Choose a reason for hiding this comment

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

Can this line be inside if (ilStubInterpData != NULL) as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can add an assert before this line and do the rest unconditionally.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Copilot AI review requested due to automatic review settings February 26, 2026 14:03
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 2 out of 2 changed files in this pull request and generated 1 comment.

@radekdoulik radekdoulik requested a review from jkotas February 26, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-VM-coreclr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][coreclr] Attempt to access method System.Delegate.DelegateConstruct results in exception

3 participants