Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/9.0] Ensure the layout of StackAllocatedBox<T> matches boxed layouts #107075

Merged
merged 5 commits into from
Aug 29, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 28, 2024

Backport of #107050 to release/9.0

/cc @jakobbotsch

Customer Impact

  • Customer reported
  • Found internally

The JIT may produce silent bad codegen when stack allocating a box of a type with alignment larger than 8 (such as Int128 or Vector128). In those cases it is possible for some of the data of the struct value to be silently discarded.

Regression

  • Yes
  • No

Rare edge case not found immediately with the stack allocation work.

Testing

Internal tests failed under a JIT stress mode (#106947). The fix was manually verified on those tests with the jit stress mode applied.
Also added assert to make other potential bugs of this flavor much more easy to discover.

Risk

Low.

The boxed layout of a struct always has its data at +8, as evidenced by
`Object::UnBox`. This means that `StackAllocatedBox<T>` should have
`Pack = 1`, otherwise this may not be the case. In the test failure we
had a `StackAllocatedBox<Int128>` which had its `_value` field at offset
16. After object stack allocation this meant that we were saving data in
padding of the structure, which promotion does not guarantee to
preserve.

Fix #106947
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@ergunr

This comment was marked as off-topic.

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

lgtm. we can merge when ready

@jeffschwMSFT jeffschwMSFT added the Servicing-approved Approved for servicing release label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants