summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-04-02 21:12:17 +0000
committerEric Fiselier <eric@efcs.ca>2015-04-02 21:12:17 +0000
commit9a37bc91d2d8a60f7872546f72d98123ae2288f6 (patch)
tree8df97715525cbdc42d0eaf109fe45dd7f5dec1d1 /libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
parent4453d2185c43fafee3c74ad95ecbd87d8b2e97ef (diff)
downloadbcm5719-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.assign/move.pass.cpp')
-rw-r--r--libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
index 94a30e74218..2db9430a698 100644
--- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
+++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
@@ -48,13 +48,16 @@ int main()
{
assert(G::n_alive == 0);
assert(!G::op_run);
- std::thread t0(G(), 5, 5.5);
+ {
+ G g;
+ std::thread t0(g, 5, 5.5);
std::thread::id id = t0.get_id();
std::thread t1;
t1 = std::move(t0);
assert(t1.get_id() == id);
assert(t0.get_id() == std::thread::id());
t1.join();
+ }
assert(G::n_alive == 0);
assert(G::op_run);
}
OpenPOWER on IntegriCloud