r174529 - Eliminate a race condition with the global module index.

Douglas Gregor dgregor at apple.com
Wed Feb 6 10:08:37 PST 2013


Author: dgregor
Date: Wed Feb  6 12:08:37 2013
New Revision: 174529

URL: http://llvm.org/viewvc/llvm-project?rev=174529&view=rev
Log:
Eliminate a race condition with the global module index.

Essentially, a module file on disk could change size between the time
we stat() it and the time we open it, and we need to be robust against
such a problem.

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

Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=174529&r1=174528&r2=174529&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Wed Feb  6 12:08:37 2013
@@ -536,7 +536,8 @@ namespace {
 bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) {
   // Open the module file.
   OwningPtr<llvm::MemoryBuffer> Buffer;
-  Buffer.reset(FileMgr.getBufferForFile(File));
+  std::string ErrorStr;
+  Buffer.reset(FileMgr.getBufferForFile(File, &ErrorStr, /*isVolatile=*/true));
   if (!Buffer) {
     return true;
   }





More information about the cfe-commits mailing list