Author: Sam McCall Date: 2021-02-16T16:58:17-08:00 New Revision: f23ee06ec27e991f9f1fbb646f3a2288aeedee71
URL: https://github.com/llvm/llvm-project/commit/f23ee06ec27e991f9f1fbb646f3a2288aeedee71 DIFF: https://github.com/llvm/llvm-project/commit/f23ee06ec27e991f9f1fbb646f3a2288aeedee71.diff LOG: [clangd] Fix race in Global CDB shutdown I believe the atomic write can be reordered after the notify, and that seems to be happening on mac m1: http://45.33.8.238/macm1/2654/step_8.txt In practice maybe seq_cst is enough? But no reason not to lock here. https://bugs.llvm.org/show_bug.cgi?id=48998 (cherry picked from commit 6ac3fd9706047304c52a678884122a3a6bc55432) Added: Modified: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp index 1a5379acfe7d..542d0c3e4dbc 100644 --- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp +++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp @@ -34,6 +34,7 @@ #include <atomic> #include <chrono> #include <condition_variable> +#include <mutex> #include <string> #include <tuple> #include <vector> @@ -567,7 +568,10 @@ class DirectoryBasedGlobalCompilationDatabase::BroadcastThread { } ~BroadcastThread() { - ShouldStop.store(true, std::memory_order_release); + { + std::lock_guard<std::mutex> Lock(Mu); + ShouldStop.store(true, std::memory_order_release); + } CV.notify_all(); Thread.join(); } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits