Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Port #22775 into release/2.1#24858

Merged
jashook merged 2 commits intodotnet:release/2.1from
jashook:port_22775
Jun 4, 2019
Merged

Port #22775 into release/2.1#24858
jashook merged 2 commits intodotnet:release/2.1from
jashook:port_22775

Conversation

@jashook
Copy link

@jashook jashook commented May 30, 2019

Port #22775 into release/2.1

Fixes #24676

Set flag in comp info to signal that a caller has >8 byte struct args

This will be used by fgCanFastTailCall to correctly determine whether an arm64
or x64 linux caller/callee can fastTailCall. It is also a workaround to #12468 to catch early any slot shuffling that would happen in LowerFastTailCall. Which currently assumes all parameters are one slot size.

…dotnet#22775)

* Set flag in comp info to signal that a caller has >8 byte struct args

This will be used by fgCanFastTailCall to correctly determine whether an arm64
or x64 linux caller/callee can fastTailCall.
It is also a workaround to #12468 to catch early any slot shuffling that would happen in LowerFastTailCall. Which currently assumes all parameters are one slot size.

* Address feedback

* Apply format patch

* Add comment

* apply new format patch
@jashook jashook changed the title Set flag in comp info to signal that a caller has >8 byte struct args… Port #22775 into release/2.1 May 30, 2019
@jashook
Copy link
Author

jashook commented May 30, 2019

Description

When running on x64 unix, in code that creates a valid fastTailCall candidate which has a >8 byte <17 byte struct and requires the caller to use stack space, we will correctly setup the incoming and outgoing arguments to pass an 8 byte struct in two registers. However, due to #12468, an algorithm which relies on properties of the Windows ABI we will incorrectly setup setup the outgoing arguments to the callee.

Customer Impact

This bug causes a crash in Automapper running x64 *nix on .Net Core 2.1 and .Net Core 2.2

Regression?

This is not a regression, the bug has existed since release/1.0. It was an bug that was not caught during x64 unix bringup.

Risk

This bug in release will at best crash, at worse it will produce silent bad codegen. Which would most likely copy in junk off the frame into random arguments passed to the caller. Worst case is it would copy in somewhat valid junk and produce unexpected results.

That being said it requires a few unique things to create the error:

  1. The user has to pass a >8byte <17 byte struct
  2. The user must have a fast tail call case, which has the following restrictions
    1. Not an inline candidate
    2. number of caller args > number callee args
    3. callee must have only enregisterable arguments.
  3. The caller must pass enough arguments to use all available argument registers and use stack space

@jashook
Copy link
Author

jashook commented May 30, 2019

/cc @RussKeldorph @AndyAyersMS note I am currently manually testing the fix on Windows x64 and Unix x64. This change technically affects arm64, but I am opting to not test on the platform as it is not supported for release/2.1

@RussKeldorph RussKeldorph added the Servicing-consider Issue for next servicing release review label May 30, 2019
@RussKeldorph RussKeldorph added this to the 2.1.x milestone May 30, 2019
Copy link

@briansull briansull left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

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

LGTM

@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels May 30, 2019
@jashook
Copy link
Author

jashook commented Jun 4, 2019

Windows testing is not currently possible in 2.1 due to https://github.com/dotnet/coreclr/issues/24922. This change has little risk to regress Windows, and has been tested in master. I will continue working on https://github.com/dotnet/coreclr/issues/24922 and run the tests manually after.

@jashook jashook merged commit 6f78fbb into dotnet:release/2.1 Jun 4, 2019
@jashook jashook deleted the port_22775 branch June 4, 2019 18:17
@jashook
Copy link
Author

jashook commented Jun 6, 2019

Windows has been tested, no regressions from this change. Will merge to 2.2

jashook pushed a commit that referenced this pull request Jun 6, 2019
* Set flag in comp info to signal that a caller has >8 byte struct args (#22775)

* Set flag in comp info to signal that a caller has >8 byte struct args

This will be used by fgCanFastTailCall to correctly determine whether an arm64
or x64 linux caller/callee can fastTailCall.
It is also a workaround to #12468 to catch early any slot shuffling that would happen in LowerFastTailCall. Which currently assumes all parameters are one slot size.

* Address feedback

* Apply format patch

* Add comment

* apply new format patch

* Address feedback and add header
@vivmishra vivmishra modified the milestones: 2.1.x, 2.1.12 Jul 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants