Skip to content

[release/8.0-staging] Call the Copy Constructor for stack arguments in C++/CLI on x86 - #100221

Merged
AaronRobinsonMSFT merged 3 commits into
dotnet:release/8.0-stagingfrom
AaronRobinsonMSFT:port_100050_net8
Mar 30, 2024
Merged

[release/8.0-staging] Call the Copy Constructor for stack arguments in C++/CLI on x86#100221
AaronRobinsonMSFT merged 3 commits into
dotnet:release/8.0-stagingfrom
AaronRobinsonMSFT:port_100050_net8

Conversation

@AaronRobinsonMSFT

@AaronRobinsonMSFTAaronRobinsonMSFT commented Mar 25, 2024

Copy link
Copy Markdown
Member

This is a port of #100050 to .NET 8.

/cc @jeffschwMSFT@agocke@jkotas

Customer Impact

  • Customer reported
  • Found internally

See user reported issue #100033.

The DTS bug contains the repro. Essentially, a copy ctor of std::vector<>::iterator is not called when pushing the argument onto the stack for the call to the native method, which takes an argument of type iterator. This leads to STL's iterator debugging book-keeping code to later assert.

This happens only for x86 and does not repro in the desktop framework where the copy ctor is correctly called.

The workaround is to disable debug iterators or change the legacy code to avoid the problematic pattern. Both of these are unacceptable long-term in-production fixes.

Regression

  • Yes
  • No

Regression introduced from .NET Framework. Support was added in .NET Core 3.1 and included the regression - dotnet/coreclr#22805.

Testing

A test was added that validates the issue in a C++/CLI scenario.

Risk

Low

…86 (dotnet#100050)
* Add repro test case
* Directly load the argument address using ldarga to avoid making a copy
* Reimplement the "Copy Constructor Cookie" logic in a more modern and maintainable style to get the test passing again
* Narrow support to Windows only
---------
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
@AaronRobinsonMSFTAaronRobinsonMSFT added Servicing-consider Issue for next servicing release review area-Interop-coreclr labels Mar 25, 2024
@AaronRobinsonMSFTAaronRobinsonMSFT added this to the 8.0.x milestone Mar 25, 2024
@AaronRobinsonMSFT
AaronRobinsonMSFT marked this pull request as ready for review March 25, 2024 02:59

@jkotasjkotas left a comment

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 would avoid the additional cleanup in the servicing backport.

Comment threadsrc/coreclr/vm/ilmarshalers.cpp Outdated
Comment threadsrc/coreclr/vm/ilmarshalers.cpp
Comment threadsrc/coreclr/vm/ilmarshalers.cpp
Comment threadsrc/coreclr/vm/ilmarshalers.cpp
Comment threadsrc/coreclr/vm/ilmarshalers.cpp Outdated
Comment threadsrc/coreclr/vm/mlinfo.cpp Outdated
Comment threadsrc/coreclr/vm/mlinfo.cpp Outdated
Comment threadsrc/coreclr/vm/mlinfo.cpp Outdated
Comment threadsrc/coreclr/vm/mtypes.h Outdated
Comment threadsrc/coreclr/vm/mtypes.h Outdated
@AaronRobinsonMSFT

Copy link
Copy Markdown
MemberAuthor

I would avoid the additional cleanup in the servicing backport.

Sounds good. I wasn't sure how much effort we wanted to narrow the changes. I just tried applying them without a local build. If there is any fallout, I will look again tomorrow.

@jeffschwMSFTjeffschwMSFT left a comment

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.

approved. we will take for consideration in 8.0.x

@rbhandarbhanda modified the milestones: 8.0.x, 8.0.5Mar 26, 2024
@rbhandarbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Mar 26, 2024
@AaronRobinsonMSFT
AaronRobinsonMSFT merged commit ba9df1e into dotnet:release/8.0-stagingMar 30, 2024
@AaronRobinsonMSFT
AaronRobinsonMSFT deleted the port_100050_net8 branch March 30, 2024 15:20
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Apr 30, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Interop-coreclrServicing-approvedApproved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@AaronRobinsonMSFT@agocke@jkotas@jeffschwMSFT@rbhanda@jkoritzinsky