Author: benlangmuir Date: Wed Oct 21 18:12:45 2015 New Revision: 250963 URL: http://llvm.org/viewvc/llvm-project?rev=250963&view=rev Log: 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! rdar://23181512 Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp 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) return; + // 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); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits