Skip to content

Conversation

@davidwrighton
Copy link
Member

  • Add detection for attempting to call function with this call calling convention without actually passing a this argument.

- Add detection for attempting to call function with this call calling convention without actually passing a this argument.
@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.

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

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 adds validation to detect an invalid scenario in the CoreCLR interpreter where a function using an instance method calling convention (such as thiscall, CMemberFunction, etc.) is called with zero arguments. Instance method calling conventions require at least one argument (the 'this' pointer), so calling such a function with zero arguments is invalid code.

Key changes:

  • New validation function CheckForPInvokeThisCallWithNoArgs detects the invalid scenario
  • Check is applied to both calli instructions and regular PInvoke calls
  • Error message matches the existing check in the JIT compiler

Reviewed changes

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

File Description
src/coreclr/interpreter/compiler.h Adds declaration for the new validation function
src/coreclr/interpreter/compiler.cpp Implements the validation function and adds calls at two locations: for calli instructions and for direct PInvoke calls

@davidwrighton davidwrighton merged commit 181d608 into dotnet:main Jan 7, 2026
95 of 98 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants