diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-04-02 21:12:17 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-04-02 21:12:17 +0000 |
commit | 9a37bc91d2d8a60f7872546f72d98123ae2288f6 (patch) | |
tree | 8df97715525cbdc42d0eaf109fe45dd7f5dec1d1 /libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp | |
parent | 4453d2185c43fafee3c74ad95ecbd87d8b2e97ef (diff) | |
download | bcm5719-llvm-9a37bc91d2d8a60f7872546f72d98123ae2288f6.tar.gz bcm5719-llvm-9a37bc91d2d8a60f7872546f72d98123ae2288f6.zip |
Fix race conditions in test class used throughout the std::thread tests.
The test class 'G' reads and writes to the same static variables in its
constructor, destructor and call operator. When threads are
constructed using `std::thread t((G()))` there is a race condition between the
destruction of the temporary and the execution of `G::operator()()`.
The fix is to simply create the input before creating the thread.
llvm-svn: 233946
Diffstat (limited to 'libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp')
-rw-r--r-- | libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp index 20c8da1de92..ddf96d09573 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp @@ -9,6 +9,9 @@ // // UNSUPPORTED: libcpp-has-no-threads +// NOTE: TSAN will report this test as leaking a thread. +// XFAIL: tsan + // <thread> // class thread @@ -53,8 +56,11 @@ int main() { assert(G::n_alive == 0); assert(!G::op_run); - std::thread t((G())); - std::this_thread::sleep_for(std::chrono::milliseconds(250)); + G g; + { + std::thread t(g); + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } } assert(false); } |