Skip to content

Conversation

@davidwrighton
Copy link
Member

  • Handle the case where the dispatch may get upgraded from a PInvokeImportThunk to a direct function pointer

…nvolved

- Handle the case where the dispatch may get upgraded from a PInvokeImportThunk to a direct function pointer
Copilot AI review requested due to automatic review settings September 29, 2025 21:27
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 interop calls in the CLR interpreter when PInvokePrecodeImport thunks are involved by handling cases where the dispatch method may be upgraded from a PInvokeImportThunk to a direct function pointer during multi-threaded execution.

Key changes:

  • Adds logic to detect and handle PInvokeImportPrecode targets
  • Updates target validation to accommodate both precode and direct function pointers
  • Implements thread-safe target updates using volatile operations

Reviewed Changes

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

File Description
src/coreclr/vm/interpexec.cpp Adds GetTargetPInvokeMethodDesc function and updates InvokeManagedMethod to handle PInvokeImportPrecode race conditions
src/coreclr/vm/callstubgenerator.h Makes SetTarget and GetTarget operations thread-safe using volatile store/load

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

davidwrighton and others added 2 commits September 29, 2025 15:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@davidwrighton davidwrighton enabled auto-merge (squash) September 29, 2025 23:12
@davidwrighton davidwrighton merged commit a2f46fc into dotnet:main Sep 30, 2025
98 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants