[cfe-commits] r137383 - /cfe/trunk/lib/Serialization/ASTReader.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Aug 11 16:26:42 PDT 2011


Author: akirtzidis
Date: Thu Aug 11 18:26:42 2011
New Revision: 137383

URL: http://llvm.org/viewvc/llvm-project?rev=137383&view=rev
Log:
Fix a PCH crash bug where we kept a reference inside a DenseMap while the map was getting modified.

No test case, sorry. It's one of those bugs where it's really really hard to make one. rdar://9910862.

Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=137383&r1=137382&r2=137383&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Aug 11 18:26:42 2011
@@ -4307,7 +4307,10 @@
   // There might be visible decls in multiple parts of the chain, for the TU
   // and namespaces. For any given name, the last available results replace
   // all earlier ones. For this reason, we walk in reverse.
-  DeclContextInfos &Infos = DeclContextOffsets[DC];
+  // Copy the DeclContextInfos vector instead of using a reference to the
+  // vector stored in the map, because DeclContextOffsets can change while
+  // we load declarations with GetLocalDeclAs.
+  DeclContextInfos Infos = DeclContextOffsets[DC];
   for (DeclContextInfos::reverse_iterator I = Infos.rbegin(), E = Infos.rend();
        I != E; ++I) {
     if (!I->NameLookupTableData)





More information about the cfe-commits mailing list