Author: Sam McCall Date: 2020-01-27T14:44:44+01:00 New Revision: 2c9cb89d0d00dc8669410a7d57ada11c5f7f8409
URL: https://github.com/llvm/llvm-project/commit/2c9cb89d0d00dc8669410a7d57ada11c5f7f8409 DIFF: https://github.com/llvm/llvm-project/commit/2c9cb89d0d00dc8669410a7d57ada11c5f7f8409.diff LOG: [Support] Fix race in threading test, found by TSan (cherry picked from commit 18e6a65bae93a7bf0e718415b394fe4b0f09221e) Added: Modified: llvm/unittests/Support/Threading.cpp Removed: ################################################################################ diff --git a/llvm/unittests/Support/Threading.cpp b/llvm/unittests/Support/Threading.cpp index 21baa55ef443..183c9aa7d71c 100644 --- a/llvm/unittests/Support/Threading.cpp +++ b/llvm/unittests/Support/Threading.cpp @@ -32,8 +32,10 @@ class Notification { { std::lock_guard<std::mutex> Lock(M); Notified = true; + // Broadcast with the lock held, so it's safe to destroy the Notification + // after wait() returns. + CV.notify_all(); } - CV.notify_all(); } bool wait() { _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits