-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Patch a Source of Iterator Invalidation #31640
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getOpaqueResultTypeDecl() can wind up invoking lazy function body parsing when it runs availability checking. If any of those function bodies have opaque result types, they will be inserted. If that insertion happens to resize the SetVector, iterators will be invalidated and a non-deterministic crash results. Instead, use SetVector::takeVector() for the iteration so we have a temporary copy whose iterators cannot be invalidated in this situation. This also elegantly handles clearing out the vector for us. Resolves rdar://62976771
@swift-ci test |
@swift-ci test source compatibility |
@swift-ci ASAN test |
@swift-ci nominate |
DougGregor
approved these changes
May 7, 2020
Build failed |
CI outage... |
@swift-ci test source compatibility |
@swift-ci ASAN test |
@swift-ci test macOS platform |
@swift-ci test Linux |
Source compat failures are a mix of stale modules and XFAILs not being propagated to the release branch. Crucially, MovieSwiftUI passes. ⛵ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #31639
getOpaqueResultTypeDecl() can wind up invoking lazy function body
parsing when it runs availability checking. If any of those function
bodies have opaque result types, they will be inserted. If that
insertion happens to resize the SetVector, iterators will be invalidated
and a non-deterministic crash results.
Instead, use SetVector::takeVector() for the iteration so we have
a temporary copy whose iterators cannot be invalidated in this
situation. This also elegantly handles clearing out the vector for us.
Scope: Iterator invalidation could occur at any point in the compiler pipeline now that lazy parsing is enabled. The crashes would most likely manifest deep in code generation where the opaque result type decls themselves are needed most.
Resolves rdar://62976771
Risk: Low
Testing: MovieSwiftUI semi-reliably reproduces this crash. Verifying the source compatibility suite and ASAN bots pass after this change suffices.
Reviewer: @DougGregor