[cfe-commits] r159664 - /cfe/trunk/lib/Frontend/ASTUnit.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Jul 3 09:30:52 PDT 2012
Author: akirtzidis
Date: Tue Jul 3 11:30:52 2012
New Revision: 159664
URL: http://llvm.org/viewvc/llvm-project?rev=159664&view=rev
Log:
[libclang] Protect against a race condition where a thread
may be destroying an ASTUnit while cleanupOnDiskMapAtExit is
getting called.
rdar://11781241
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=159664&r1=159663&r2=159664&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue Jul 3 11:30:52 2012
@@ -116,7 +116,8 @@
}
static void cleanupOnDiskMapAtExit(void) {
- // No mutex required here since we are leaving the program.
+ // Use the mutex because there can be an alive thread destroying an ASTUnit.
+ llvm::MutexGuard Guard(getOnDiskMutex());
OnDiskDataMap &M = getOnDiskDataMap();
for (OnDiskDataMap::iterator I = M.begin(), E = M.end(); I != E; ++I) {
// We don't worry about freeing the memory associated with OnDiskDataMap.
More information about the cfe-commits
mailing list