This revision was automatically updated to reflect the committed changes. Closed by commit rGc94ecf3f81ca: [clangd] Fix a race (authored by kadircet).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97366/new/ https://reviews.llvm.org/D97366 Files: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp @@ -314,8 +314,14 @@ ~AsyncCounter() { // Verify shutdown sequence was performed. // Real modules would not do this, to be robust to no ClangdServer. - EXPECT_TRUE(ShouldStop) << "ClangdServer should request shutdown"; - EXPECT_EQ(Queue.size(), 0u) << "ClangdServer should block until idle"; + { + // We still need the lock here, as Queue might be empty when + // ClangdServer calls blockUntilIdle, but run() might not have returned + // yet. + std::lock_guard<std::mutex> Lock(Mu); + EXPECT_TRUE(ShouldStop) << "ClangdServer should request shutdown"; + EXPECT_EQ(Queue.size(), 0u) << "ClangdServer should block until idle"; + } Thread.join(); }
Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp @@ -314,8 +314,14 @@ ~AsyncCounter() { // Verify shutdown sequence was performed. // Real modules would not do this, to be robust to no ClangdServer. - EXPECT_TRUE(ShouldStop) << "ClangdServer should request shutdown"; - EXPECT_EQ(Queue.size(), 0u) << "ClangdServer should block until idle"; + { + // We still need the lock here, as Queue might be empty when + // ClangdServer calls blockUntilIdle, but run() might not have returned + // yet. + std::lock_guard<std::mutex> Lock(Mu); + EXPECT_TRUE(ShouldStop) << "ClangdServer should request shutdown"; + EXPECT_EQ(Queue.size(), 0u) << "ClangdServer should block until idle"; + } Thread.join(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits