[PATCH] D65915: [clang-doc] Protect Index with mutex during reducing and generation stage
This revision was automatically updated to reflect the committed changes. Closed by commit rL368313: [clang-doc] Protect Index with mutex during reducing and generation stage (authored by DiegoAstiazaran, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D65915?vs=214047=214178#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65915/new/ https://reviews.llvm.org/D65915 Files: clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp Index: clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp === --- clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp +++ clang-tools-extra/trunk/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 @@ llvm::outs() << "Reducing " << USRToBitcode.size() << " infos...\n"; std::atomic 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 @@ 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"; Index: clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp === --- clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp +++ clang-tools-extra/trunk/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 @@ llvm::outs() << "Reducing " << USRToBitcode.size() << " infos...\n"; std::atomic 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 @@ 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"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D65915: [clang-doc] Protect Index with mutex during reducing and generation stage
juliehockett accepted this revision. juliehockett added a comment. This revision is now accepted and ready to land. LGTM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65915/new/ https://reviews.llvm.org/D65915 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D65915: [clang-doc] Protect Index with mutex during reducing and generation stage
DiegoAstiazaran created this revision. DiegoAstiazaran added a reviewer: juliehockett. DiegoAstiazaran added a project: clang-tools-extra. Herald added subscribers: kadircet, arphaman, ilya-biryukov. Idx in ClangDocContext instance was being modified by multiple threads causing a seg fault. A mutex is added to avoid this. https://reviews.llvm.org/D65915 Files: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp === --- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ 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 @@ llvm::outs() << "Reducing " << USRToBitcode.size() << " infos...\n"; std::atomic 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 @@ 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"; Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp === --- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ 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 @@ llvm::outs() << "Reducing " << USRToBitcode.size() << " infos...\n"; std::atomic 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 @@ 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"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits