Prevent Thread Exited/Joined events race
authorKamil Rytarowski <n54@gmx.com>
Sun, 26 Nov 2017 20:20:42 +0000 (20:20 +0000)
committerKamil Rytarowski <n54@gmx.com>
Sun, 26 Nov 2017 20:20:42 +0000 (20:20 +0000)
commit7160c2f770a44020c821bf44436132d623fb558d
treecae3df415115e9d8ef1f04f225e671e009f85599
parent61145d5c2538749f2b8892ef8f1eea3ec485c6b2
Prevent Thread Exited/Joined events race

Summary:
Add atomic verification to ensure that Thread is Joined after marking it
Finished.

It is required for NetBSD in order to prevent Thread Exited/Joined race,
that may occur when native system libpthread(3) cannot be reliably traced
in a way to guarantee that the mentioned events happen one after another.

This change fixes at least TSan and LSan on NetBSD.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, dvyukov, vitalybuka

Reviewed By: dvyukov

Subscribers: llvm-commits, kubamracek, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D40294

llvm-svn: 319004
compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cc
compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h