Skip to content

Conversation

@janvorli
Copy link
Member

@janvorli janvorli commented Dec 3, 2025

The recent fix to handle alignment of the first argument of a delegate call when we were removing the delegate obj from the stack was not complete. It only handled the case when the first argument required 16 byte alignment. But the same issue exists if any of the args requires this alignment.

This change fixes it by finding the first argument that requires 16 byte alignment and then moving the args before that as usual and moving that arg and all following ones to 16 byte aligned location. This preserves the alignment for the rest of the stuff too.

The recent fix to handle alignment of the first argument of a delegate
call when we were removing the delegate obj from the stack was not
complete. It only handled the case when the first argument required
16 byte alignment. But the same issue exists if any of the args requires
this alignment.

This change fixes it by finding the first argument that requires 16 byte
alignment and then moving the args before that as usual and moving
that arg and all following ones to 16 byte aligned location. This preserves
the alignment for the rest of the stuff too.
@janvorli janvorli added this to the 11.0.0 milestone Dec 3, 2025
@janvorli janvorli self-assigned this Dec 3, 2025
@janvorli janvorli requested a review from BrzVlad as a code owner December 3, 2025 23:43
Copilot AI review requested due to automatic review settings December 3, 2025 23:43
@janvorli janvorli requested a review from kg as a code owner December 3, 2025 23:43
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 bug in the interpreter's delegate argument alignment handling when removing the delegate object from the argument list. The previous fix only handled the case where the first argument required 16-byte alignment, but the issue also occurred when any argument required this alignment.

Key Changes:

  • Modified the compiler to calculate the size of all arguments up to (but not including) the first 16-byte aligned argument
  • Updated the runtime execution to properly shift arguments in two phases: non-aligned arguments first, then aligned arguments to their correct 16-byte boundaries

Reviewed changes

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

File Description
src/coreclr/interpreter/compiler.cpp Changed from calculating offset of first target argument to calculating cumulative size of all target arguments before the first 16-byte aligned argument
src/coreclr/vm/interpexec.cpp Modified argument shifting logic to use two separate memmove operations: one for non-aligned arguments and one for aligned arguments, preserving 16-byte alignment where required

@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

@davidwrighton davidwrighton left a comment

Choose a reason for hiding this comment

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

Copilot looks like it might have a point, but otherwise things look good.

@janvorli
Copy link
Member Author

janvorli commented Dec 4, 2025

/ba-g the failures are #122185 and #122169

@janvorli janvorli merged commit 5616397 into dotnet:main Dec 4, 2025
96 of 99 checks passed
@janvorli janvorli deleted the fix-delegate-args-alignment-take-2 branch December 4, 2025 22:39
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.

4 participants