Skip to content

Commit ba1facf

Browse files
committed
ASTContext: Recompute the insert position in getSpecializedConformance 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
1 parent 31b511e commit ba1facf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/AST/ASTContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,8 @@ ASTContext::getSpecializedConformance(Type type,
18351835
auto result
18361836
= new (*this, arena) SpecializedProtocolConformance(type, generic,
18371837
substitutions);
1838+
auto node = specializedConformances.FindNodeOrInsertPos(id, insertPos);
1839+
assert(!node);
18381840
specializedConformances.InsertNode(result, insertPos);
18391841
return result;
18401842
}

0 commit comments

Comments
 (0)