Skip to content

[5.3] MandatoryInlining: fix a memory lifetime bug related to partial_apply with in_guaranteed parameters. #32381

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

Merged

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Jun 15, 2020

This is a cherry-pick of #32317.


Explanation: When creating a closure context, all captured arguments are taken "owned". We failed to copy arguments which are address-only ("indirect arguments"). An assert build of the compiler asserts with a memory lifetime failure. But a non-assert build can show different symptoms. In the reported bug the compiler just hangs. It could also be that a non-assert compiler produces a miscompile.

Scope: It affects closures which capture non-trivial arguments by address (indirect arguments). It's not a new bug and I'm surprised that we didn't see this earlier.

Risk: Low. The logic to fix the problem was just taken from direct arguments.

Testing: Added a validation test

Reviewed by: @gottesmm

Resolves: rdar://problem/64035105

… with in_guaranteed parameters.

Because partial_apply consumes it's arguments we need to copy them. This was done for "direct" parameters but not for address parameters.

rdar://problem/64035105
@eeckstein eeckstein added the r5.3 label Jun 15, 2020
@eeckstein eeckstein requested a review from a team as a code owner June 15, 2020 09:56
@eeckstein
Copy link
Contributor Author

@swift-ci test

@tkremenek tkremenek merged commit 4e19cb0 into swiftlang:release/5.3 Jun 17, 2020
@eeckstein eeckstein deleted the fix-mandatory-inlining-5.3 branch April 17, 2021 15:02
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants