Skip to content

[capture-promotion] Be sure to copy_value a struct_extracted value from a promoted capture even though the value is borrowed. #10278

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
merged 1 commit into from
Jun 15, 2017

Conversation

gottesmm
Copy link
Contributor

[capture-promotion] Be sure to copy_value a struct_extracted value from a promoted capture even though the value is borrowed.

The issue here is that we know that the given value is already borrowed, so
technically, we do not need a copy. The problem is that there is still
potentially a destroy of the value that will be cloned by the closure cloner.
This results in use-after-frees.

This commit fixes the problem by inserting the relevant copy_value and changing
the borrowed value into a +1 copy.

This is a bug that would have been caught by the Ownership verifier since a
borrowed value can not be destroyed (so the verifier would have tripped).

rdar://32625475

…om a promoted capture even though the value is borrowed.

The issue here is that we know that the given value is already borrowed, so
technically, we do not need a copy. The problem is that there is still
potentially a destroy of the value that will be cloned by the closure cloner.
This results in use-after-frees.

This commit fixes the problem by inserting the relevant copy_value and changing
the borrowed value into a +1 copy.

This is a bug that would have been caught by the Ownership verifier since a
borrowed value can not be destroyed (so the verifier would have tripped).

rdar://32625475
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants