Skip to content

ASTContext: Recompute the insert position in getSpecializedConformanc… #17904

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

aschwaighofer
Copy link
Contributor

…e after the SpecializedProtocolConformance constructor

The constructor can modify the SpecializedConformances FoldingSet so that the
insertPos is no longer valid. It calls computeConditionalRequirements which
calls Type::subst which recursively can call getSpecializedConformance again.

This bug manifest itself either as memory error with libgmalloc or as
spurious errors later on.

rdar://42082352

…e after the SpecializedProtocolConformance constructor

The constructor can modify the SpecializedConformances FoldingSet so that the
insertPos is no longer valid. It calls computeConditionalRequirements which
calls Type::subst which recursively can call getSpecializedConformance again.

This bug manifest itself either as memory error with libgmalloc or as
spurious errors later on.

rdar://42082352
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@aschwaighofer aschwaighofer requested a review from DougGregor July 12, 2018 17:31
@@ -1835,6 +1835,8 @@ ASTContext::getSpecializedConformance(Type type,
auto result
= new (*this, arena) SpecializedProtocolConformance(type, generic,
substitutions);
auto node = specializedConformances.FindNodeOrInsertPos(id, insertPos);
assert(!node);
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll get an unused variable warning on this in a no-asserts build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, right thanks!

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ba1facf

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - ba1facf

@aschwaighofer aschwaighofer merged commit fd1baff into swiftlang:master Jul 12, 2018
DougGregor added a commit to DougGregor/swift that referenced this pull request Jul 26, 2018
Arnold fixed this by re-computing the insert position in
getSpecializedConformance(), with
swiftlang#17904.

Fixes rdar://problem/35797159.
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.

3 participants