summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Astiazaran <diegoaat97@gmail.com>2019-08-08 17:14:17 +0000
committerDiego Astiazaran <diegoaat97@gmail.com>2019-08-08 17:14:17 +0000
commite2d4577075f67cd4cb0776c2d14d399e5d147666 (patch)
tree08491a93b249054306ce8b90db80abc9e107db09
parent09a7a627af08f00722aa3eeb20ee7530a178c61c (diff)
downloadbcm5719-llvm-e2d4577075f67cd4cb0776c2d14d399e5d147666.tar.gz
bcm5719-llvm-e2d4577075f67cd4cb0776c2d14d399e5d147666.zip
[clang-doc] Protect Index with mutex during reducing and generation stage
Idx in ClangDocContext instance was being modified by multiple threads causing a seg fault. A mutex is added to avoid this. Differential Revision: https://reviews.llvm.org/D65915 llvm-svn: 368313
-rw-r--r--clang-tools-extra/clang-doc/tool/ClangDocMain.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 044bba7a025..fb1ed5b9421 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -36,6 +36,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Mutex.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
@@ -246,6 +247,7 @@ int main(int argc, const char **argv) {
llvm::outs() << "Reducing " << USRToBitcode.size() << " infos...\n";
std::atomic<bool> Error;
Error = false;
+ llvm::sys::Mutex IndexMutex;
// ExecutorConcurrency is a flag exposed by AllTUsExecution.h
llvm::ThreadPool Pool(ExecutorConcurrency == 0 ? llvm::hardware_concurrency()
: ExecutorConcurrency);
@@ -289,8 +291,10 @@ int main(int argc, const char **argv) {
return;
}
+ IndexMutex.lock();
// Add a reference to this Info in the Index
clang::doc::Generator::addInfoToIndex(CDCtx.Idx, I);
+ IndexMutex.unlock();
if (auto Err = G->get()->generateDocForInfo(I, InfoOS, CDCtx))
llvm::errs() << toString(std::move(Err)) << "\n";
OpenPOWER on IntegriCloud