[libcxx] Add Atomic test helper and fix TSAN failures.

Summary:
This patch attempts to fix the last 3 TSAN failures on the libc++ bot (http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-tsan/builds/143). This patch also adds a `Atomic` test type that can be used where `<atomic>` cannot.

`wait.exception.pass.cpp` and `wait_for.exception.pass.cpp` were failing because the test replaced `std::terminate` with `std::exit`. `std::exit` would asynchronously run the TLS and static destructors and this would cause a race condition. See PR22606 and D8802 for more details. 

This is fixed by using `_Exit` to prevent cleanup.

`notify_all_at_thread_exit.pass.cpp` exercises the same race condition but for different reasons. I fixed this test by manually joining the thread before beginning program termination.

Reviewers: EricWF, mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11046

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245389 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2015-08-18 23:29:59 +00:00
parent 3b1fb53a65
commit 286e0a491b
8 changed files with 257 additions and 136 deletions

View File

@@ -22,6 +22,8 @@
#include <cstdlib>
#include <cassert>
#include "test_macros.h"
unsigned throw_one = 0xFFFF;
void* operator new(std::size_t s) throw(std::bad_alloc)
@@ -75,7 +77,7 @@ public:
int G::n_alive = 0;
bool G::op_run = false;
#ifndef _LIBCPP_HAS_NO_VARIADICS
#if TEST_STD_VER >= 11
class MoveOnly
{
@@ -137,7 +139,7 @@ int main()
assert(!G::op_run);
}
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
#if TEST_STD_VER >= 11
{
assert(G::n_alive == 0);
assert(!G::op_run);
@@ -150,5 +152,5 @@ int main()
std::thread t = std::thread(MoveOnly(), MoveOnly());
t.join();
}
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif
}