[PATCH] D143428: [clang][deps] Fix race condition
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 6 11:41:18 PST 2023
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: steven_wu.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
D140176 <https://reviews.llvm.org/D140176> introduced new `FullDeps` API that's not thread-safe, breaking the class invariant. This was causing race condition when `clang-scan-deps` was run with multiple threads.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143428
Files:
clang/tools/clang-scan-deps/ClangScanDeps.cpp
Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===================================================================
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -252,14 +252,17 @@
public:
void mergeDeps(StringRef Input, TranslationUnitDeps TUDeps,
size_t InputIndex) {
+ mergeDeps(std::move(TUDeps.ModuleGraph), InputIndex);
+
InputDeps ID;
ID.FileName = std::string(Input);
ID.ContextHash = std::move(TUDeps.ID.ContextHash);
ID.FileDeps = std::move(TUDeps.FileDeps);
ID.ModuleDeps = std::move(TUDeps.ClangModuleDeps);
- mergeDeps(std::move(TUDeps.ModuleGraph), InputIndex);
ID.DriverCommandLine = std::move(TUDeps.DriverCommandLine);
ID.Commands = std::move(TUDeps.Commands);
+
+ std::unique_lock<std::mutex> ul(Lock);
Inputs.push_back(std::move(ID));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143428.495231.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230206/472e8cd0/attachment.bin>
More information about the cfe-commits
mailing list