r250963 - Fix use-after-free in ModuleManager

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 21 16:12:45 PDT 2015

Author: benlangmuir
Date: Wed Oct 21 18:12:45 2015
New Revision: 250963

URL: http://llvm.org/viewvc/llvm-project?rev=250963&view=rev
Fix use-after-free in ModuleManager

When removing out-of-date modules we might have left behind a VisitOrder
that contains pointers to freed ModuleFiles.  This was very rarely seen,
because it only happens when modules go out of date and the VisitOrder
happens to have the right size to not be recomputed.

Thanks ASan!



Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=250963&r1=250962&r2=250963&view=diff
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Wed Oct 21 18:12:45 2015
@@ -194,6 +194,9 @@ void ModuleManager::removeModules(
   if (first == last)
+  // Explicitly clear VisitOrder since we might not notice it is stale.
+  VisitOrder.clear();
   // Collect the set of module file pointers that we'll be removing.
   llvm::SmallPtrSet<ModuleFile *, 4> victimSet(first, last);

More information about the cfe-commits mailing list