Skip to content

[interp] Verify stack depth for return opcodes#118976

Merged
kg merged 1 commit into
dotnet:mainfrom
kg:interp-cee-ret-check
Aug 22, 2025
Merged

[interp] Verify stack depth for return opcodes#118976
kg merged 1 commit into
dotnet:mainfrom
kg:interp-cee-ret-check

Conversation

@kg

@kg kg commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

Fixes JIT\regression\jitblue\GitHub_25027

Copilot AI review requested due to automatic review settings August 21, 2025 23:30
@kg
kg requested review from BrzVlad and janvorli as code owners August 21, 2025 23:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 stack depth verification for return opcodes in the CoreCLR interpreter to ensure the evaluation stack has exactly the expected number of items when returning from a method. This addresses a regression test failure in GitHub_25027.

Key changes:

  • Introduces a new CheckStackExact method that validates the stack has precisely the expected depth
  • Replaces existing CHECK_STACK calls with CheckStackExact for return operations to catch both stack underflow and overflow conditions

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 new CheckStackExact method
src/coreclr/interpreter/compiler.cpp Implements CheckStackExact and applies it to return opcodes for precise stack validation
Comments suppressed due to low confidence (2)

src/coreclr/interpreter/compiler.cpp:3928

  • The removed CHECK_STACK(1) call should be documented or explained in the commit message why it was replaced, as this represents a behavior change from checking minimum stack depth to exact stack depth.
                {

src/coreclr/interpreter/compiler.cpp:3947

  • The removed CHECK_STACK(1) call should be documented or explained in the commit message why it was replaced, as this represents a behavior change from checking minimum stack depth to exact stack depth.
                CHECK_STACK(1);

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@kg
kg merged commit b2c99a0 into dotnet:main Aug 22, 2025
96 of 98 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 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