[llvm] 18e6a65 - [Support] Fix race in threading test, found by TSan

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 05:48:25 PST 2020


Cherry-picked to 10.x in 2c9cb89d0d00dc8669410a7d57ada11c5f7f8409

On Sat, Jan 25, 2020 at 6:22 AM Sam McCall via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
>
> Author: Sam McCall
> Date: 2020-01-25T15:22:12+01:00
> New Revision: 18e6a65bae93a7bf0e718415b394fe4b0f09221e
>
> URL: https://github.com/llvm/llvm-project/commit/18e6a65bae93a7bf0e718415b394fe4b0f09221e
> DIFF: https://github.com/llvm/llvm-project/commit/18e6a65bae93a7bf0e718415b394fe4b0f09221e.diff
>
> LOG: [Support] Fix race in threading test, found by TSan
>
> 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-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list