Skip to content

Fix return type misclasiffication in TransitionBlock.cs#129143

Open
janvorli wants to merge 1 commit into
dotnet:mainfrom
janvorli:fix-eightbyte-return-misclassification
Open

Fix return type misclasiffication in TransitionBlock.cs#129143
janvorli wants to merge 1 commit into
dotnet:mainfrom
janvorli:fix-eightbyte-return-misclassification

Conversation

@janvorli

@janvorli janvorli commented Jun 8, 2026

Copy link
Copy Markdown
Member

The ComputeReturnValueTreatment has a typo that causes wrong return type classification for structs passed in registers on x64 Unix. It causes wrong classification when there are two eightbytes, the first eightbyte is classified as SystemVClassificationTypeSSE and the second one is not. It may lead to GC hole in that case.

The ComputeReturnValueTreatment has a typo that causes wrong return type
classification for structs passed in registers on x64 Unix. It causes
wrong classification when there are two eightbytes, the first eightbyte
is classified as SystemVClassificationTypeSSE and the second one is not.
It may lead to GC hole in that case.
@janvorli janvorli added this to the 11.0.0 milestone Jun 8, 2026
@janvorli janvorli self-assigned this Jun 8, 2026
Copilot AI review requested due to automatic review settings June 8, 2026 23:12
@janvorli janvorli added the area-crossgen2-coreclr only use for closed issues label Jun 8, 2026
@janvorli

janvorli commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

This is one of the issues reported by #129042.
Thanks @NikiPn for reporting it.

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 corrects the System V AMD64 (x64 Unix) struct-return classification logic in the ReadyToRun transition block so that the second eightbyte’s classification is respected when computing the encoded FP return information.

Changes:

  • Fixes a duplicated check so the second eightbyte uses eightByteClassifications1 instead of re-checking eightByteClassifications0.

Comment on lines 365 to 375
// Size of the struct is 16 bytes
fpReturnSize = 16;
// The lowest two bits of the size encode the order of the int and SSE fields
if (descriptor.eightByteClassifications0 == SystemVClassificationType.SystemVClassificationTypeSSE)
{
fpReturnSize += 1;
}

if (descriptor.eightByteClassifications0 == SystemVClassificationType.SystemVClassificationTypeSSE)
if (descriptor.eightByteClassifications1 == SystemVClassificationType.SystemVClassificationTypeSSE)
{
fpReturnSize += 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree that a test would be nice, but I am not sure how hard it is to create a test that deterministically fails due to this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-crossgen2-coreclr only use for closed issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants