summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/thread
Commit message (Collapse)AuthorAgeFilesLines
* Fix PR30202 - notify_all_at_thread_exit seg faults if run from a raw pthread ↵Eric Fiselier2016-09-031-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | context. Summary: This patch allows threads not created using `std::thread` to use `std::notify_all_at_thread_exit` by ensuring the TL state has been initialized within `std::notify_all_at_thread_exit`. Additionally this patch "fixes" a potential oddity in `__thread_local_pointer::reset(pointer)`, which would previously delete the old thread local data. However there should *never* be old thread local data because pthread *should* null it out on thread exit. Unfortunately it's possible that pthread failed to do this according to the spec: > > Upon key creation, the value NULL shall be associated with the new key in all active threads. Upon thread creation, the value NULL shall be associated with all defined keys in the new thread. > > An optional destructor function may be associated with each key value. At thread exit, if a key value has a non-NULL destructor pointer, and the thread has a non-NULL value associated with that key, the value of the key is set to NULL, and then the function pointed to is called with the previously associated value as its sole argument. The order of destructor calls is unspecified if more than one destructor exists for a thread when it exits. > > If, after all the destructors have been called for all non-NULL values with associated destructors, there are still some non-NULL values with associated destructors, then the process is repeated. If, after at least {PTHREAD_DESTRUCTOR_ITERATIONS} iterations of destructor calls for outstanding non-NULL values, there are still some non-NULL values with associated destructors, implementations may stop calling destructors, or they may continue calling destructors until no non-NULL values with associated destructors exist, even though this might result in an infinite loop. However if pthread fails to delete the value it is probably incorrect for us to do it. Destroying the value performs all of the "at thread exit" actions registered with it but we are way past "at thread exit". Reviewers: mclow.lists, bcraig, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24159 llvm-svn: 280588
* Add "FLAKY_TEST" test directive to support re-running flaky tests.Eric Fiselier2016-08-3015-0/+30
| | | | | | | | Some of the mutex tests fail on machines with high load. This patch implements the test directive "// FLAKY_TEST" which allows a test to be run 3 times before it's considered a failure. llvm-svn: 280050
* Fix C++03 build.Eric Fiselier2016-06-301-0/+3
| | | | llvm-svn: 274274
* Make futures.overview enum tests more portable. Patch from STL@microsoft.comEric Fiselier2016-06-302-9/+16
| | | | llvm-svn: 274211
* Placate MSVC's unchecked malloc warning in thread tests.Eric Fiselier2016-06-221-1/+3
| | | | llvm-svn: 273385
* Move more _LIBCPP_VERSION tests to test/libcxx.Eric Fiselier2016-06-223-64/+0
| | | | llvm-svn: 273365
* Avoid assignment in return. Patch from STL@microsoft.comEric Fiselier2016-06-222-2/+2
| | | | llvm-svn: 273349
* Move native_handle thread tests to test/libcxxEric Fiselier2016-06-225-164/+0
| | | | llvm-svn: 273341
* Replace __cplusplus comparisons and dialect __has_feature checks with ↵Eric Fiselier2016-06-141-2/+4
| | | | | | | | | TEST_STD_VER. This is a huge cleanup that helps make the libc++ test suite more portable. Patch from STL@microsoft.com. Thanks STL! llvm-svn: 272716
* Add missing includeEric Fiselier2016-06-141-0/+2
| | | | llvm-svn: 272638
* Implement variadic lock_guard.Eric Fiselier2016-06-148-28/+410
| | | | | | | | | | | | | | | | | | | | Summary: This patch implements the variadic `lock_guard` paper. Making `lock_guard` variadic is a ABI breaking change because the specialization `lock_guard<_Mutex>` mangles differently then when it was the primary template. This change only provides variadic `lock_guard` in ABI V2 or when `_LIBCPP_ABI_VARIADIC_LOCK_GUARD` is defined. Note that in ABI V2 `lock_guard` must always be declared as a variadic template, even in C++03, in order to keep the ABI consistent. For this reason `lock_guard` is forward declared as a variadic template in all standard dialects and therefore depends on variadic templates being provided as an extension in C++03. All supported versions of Clang and GCC provide this extension. Reviewers: mclow.lists Subscribers: K-ballo, mclow.lists, cfe-commits Differential Revision: http://reviews.llvm.org/D21260 llvm-svn: 272634
* Remove unused local var. Patch from STL@microsoft.comEric Fiselier2016-06-141-1/+1
| | | | llvm-svn: 272622
* Fix TEST_HAS_NO_EXCEPTIONS misspelling in the test suite.Eric Fiselier2016-06-021-1/+1
| | | | llvm-svn: 271501
* Mark LWG issue 2250 as completeEric Fiselier2016-06-022-0/+40
| | | | llvm-svn: 271475
* Remove trailing whitespace in test suite. Approved by Marshall Clow.Eric Fiselier2016-06-011-1/+1
| | | | llvm-svn: 271435
* Cleanup non-standard tests as reported by STL@microsoft.com. NFC.Eric Fiselier2016-06-0118-31/+2
| | | | | | | | | | | | | | | This patch addresses the following issues in the test suite: 1. Move "std::bad_array_length" test from std/ to libcxx/ test directory since the feature is not a part of the standard. 2. Rename "futures.tas" test directory to "futures.task" since that is the correct stable name. 3. Move tests for "packaged_task<T>::result_type" from std/ to libcxx/ test directory since the typedef is a libc++ extension. llvm-svn: 271430
* [libcxx] Improve tests to use the UNSUPPORTED lit directiveAsiri Rathnayake2016-05-285-24/+5
| | | | | | | | | | | | | | | | | | | Quite a few libcxx tests seem to follow the format: #if _LIBCPP_STD_VER > X // Do test. #else // Empty test. #endif We should instead use the UNSUPPORTED lit directive to exclude the test on earlier C++ standards. This gives us a more accurate number of test passes for those standards and avoids unnecessary conflicts with other lit directives on the same tests. Reviewers: bcraig, ericwf, mclow.lists Differential revision: http://reviews.llvm.org/D20730 llvm-svn: 271108
* Replace one more occurrence of non-standard std:launch::any. Patch from ↵Eric Fiselier2016-04-301-3/+3
| | | | | | STL@microsoft.com llvm-svn: 268153
* Fix or move various non-standard tests.Eric Fiselier2016-04-292-115/+70
| | | | | | | | | | | | This patch does the following: * Remove <__config> includes from some container tests. * Guards uses of std::launch::any in async tests because it's an extension. * Move "test/std/extensions" to "test/libcxx/extensions" * Moves various non-standard tests including those in "sequences/vector", "std/localization" and "utilities/meta". llvm-svn: 267981
* Rename function parameters to avoid shadowing. Patch from STL@microsoft.comEric Fiselier2016-04-281-4/+4
| | | | llvm-svn: 267838
* [libcxx] Fix PR15638 - Only allocate in parent when starting a thread to ↵Eric Fiselier2016-04-201-15/+51
| | | | | | | | | | | | | | | | | | | | | prevent calling terminate. Summary: Hi, When creating a new thread libc++ performs at least 2 allocations. The first allocates a tuple of args and the functor that will be passed to the new thread. The second allocation is for the thread local storage needed internally by libc++. Currently the second allocation happens in the child thread, meaning that if it throws the program will terminate with an uncaught bad alloc. The solution to this is to allocate ALL memory in the parent thread and then pass it to the child. See https://llvm.org/bugs/show_bug.cgi?id=15638 Reviewers: mclow.lists, danalbert, jroelofs, EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13748 llvm-svn: 266851
* Guard a number of tests relying on threads support when built inRichard Barton2016-03-2310-4/+18
| | | | | | | | single-threaded mode. Differential Revision: http://reviews.llvm.org/D14731 llvm-svn: 264191
* Implement LWG2577: {shared,unique}_lock</tt> should use std::addressofMarshall Clow2016-03-1410-42/+150
| | | | llvm-svn: 263506
* Make it possible to build a no-exceptions variant of libcxx.Asiri Rathnayake2015-11-1035-0/+35
| | | | | | | | | | | | Fixes a small omission in libcxx that prevents libcxx being built when -DLIBCXX_ENABLE_EXCEPTIONS=0 is specified. This patch adds XFAILS to all those tests that are currently failing on the new -fno-exceptions library variant. Follow-up patches will update the tests (progressively) to cope with the new library variant. Change-Id: I4b801bd8d8e4fe7193df9e55f39f1f393a8ba81a llvm-svn: 252598
* Attempt to prevent flaky thread.mutex tests by once again increasing timing ↵Eric Fiselier2015-10-0112-28/+32
| | | | | | tolerances llvm-svn: 248993
* Finally get the test suite passing in C++03!!Eric Fiselier2015-08-281-0/+4
| | | | | | | | | After months of work there are only 4 tests still failing in C++03. This patch fixes those tests. All of the libc++ builders should be green. llvm-svn: 246275
* Remove empty file that arcanist createdEric Fiselier2015-08-281-0/+0
| | | | llvm-svn: 246273
* [libcxx] Mark most test/std/future tests as UNSUPPORTED in C++03Eric Fiselier2015-08-2838-603/+334
| | | | | | | | | | | | | | | | | | | | Summary: This patch marks *most* tests for `std::promise`, `std::future` and `std::shared_future` as unsupported in C++03. These tests fail in C++03 mode because they attempt to copy a `std::future` even though it is a `MoveOnly` type. AFAIK the missing move-semantics in `std::future` is the only reason these tests fail but without move semantics these classes are useless. For example even though `std::promise::set_value` and `std::promise::set_exception(...)` work in C++03 `std::promise` is still useless because we cannot call `std::promise::get_future(...)`. It might be possible to hack `std::move(...)` like we do for `std::unique_ptr` to make the move semantics work but I don't think it is worth the effort. Instead I think we should leave the `<future>` header as-is and mark the failing tests as `UNSUPPORTED`. I don't believe there are any users of `std::future` or `std::promise` in C++03 because they are so unusable. Therefore I am not concerned about losing test coverage and possibly breaking users. However because there are still parts of `<future>` that work in C++03 it would be wrong to `#ifdef` out the entire header. @mclow.lists Should we take further steps to prevent the use of `std::promise`, `std::future` and `std::shared_future` in C++03? Note: This patch also cleans up the tests and converts them to use `support/test_allocator.h` instead of a duplicate class in `test/std/futures/test_allocator.h`. Reviewers: mclow.lists Subscribers: vsk, mclow.lists, cfe-commits Differential Revision: http://reviews.llvm.org/D12135 llvm-svn: 246271
* Refactor flaky shared_mutex testsEric Fiselier2015-08-264-22/+39
| | | | llvm-svn: 246055
* Refactor and fix more flaky shared_mutex testsEric Fiselier2015-08-256-37/+123
| | | | llvm-svn: 245918
* Refactor shared_timed_mutex tests.Eric Fiselier2015-08-2221-146/+119
| | | | | | | First I removed all of the uses of _LIBCPP_STD_VER and added LIT UNSUPPORTED tags to prevent the tests from being run in older standard dialects. Second I increased the time tolerances used in some tests when testing with Thread Sanitizer because thread sanitizer make these tests take longer. llvm-svn: 245793
* Remove test_atomic.h headerEric Fiselier2015-08-193-10/+10
| | | | | | | Because <atomic> can now be used in C++03 there is no need for the test_atomic.h header. This commit removes the header and converts all usages to use <atomic> instead. llvm-svn: 245468
* Use TestAtomic instead of std::atomic so the test can run in C++03Eric Fiselier2015-08-191-2/+3
| | | | llvm-svn: 245415
* Mark std::packaged_task tests as unsupported in C++03.Eric Fiselier2015-08-1918-61/+45
| | | | | | | std::packaged_task requires variadic templates and is #ifdef out in C++03. This patch silences the tests in C++03. This patch also rewrites the .fail.cpp tests so that they use clang verify. llvm-svn: 245413
* [libcxx] Add Atomic test helper and fix TSAN failures.Eric Fiselier2015-08-187-136/+148
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 245389
* Remove sanitizer XFAILs on a test.Eric Fiselier2015-07-281-7/+0
| | | | llvm-svn: 243499
* Mark async tests as UNSUPPORTED in C++03 because it requires variadicsEric Fiselier2015-07-282-0/+2
| | | | llvm-svn: 243393
* Fix a handful of tests that fail in C++03Eric Fiselier2015-07-281-7/+3
| | | | llvm-svn: 243392
* Implement LWG#2407: 'packaged_task(allocator_arg_t, const Allocator&, F&&) ↵Marshall Clow2015-06-301-1/+1
| | | | | | should neither be constrained nor explicit' llvm-svn: 241068
* Implement N4508: shared_mutex. Reviewed as http://reviews.llvm.org/D10480Marshall Clow2015-06-308-0/+327
| | | | llvm-svn: 241067
* LWG2442: call_once() shouldn't DECAY_COPY(). Patch from K-Ballo.Eric Fiselier2015-06-131-1/+47
| | | | | | | This patch fixes LWG issue 2422 by removing the DECAY_COPY from call once. The review can be found here: http://reviews.llvm.org/D10191 llvm-svn: 239654
* Fix PR23293 - Do not unlock shared state before notifying consumers.Eric Fiselier2015-06-121-0/+67
| | | | | | | | Within the shared state methods do not unlock the lock guards manually. This could cause a race condition where the shared state is destroyed before the method is complete. llvm-svn: 239577
* Change #ifdefs in test to UNSUPPORTED. No functionality change in the testsMarshall Clow2015-06-119-48/+10
| | | | llvm-svn: 239562
* Get thread sleep_for test passing in C++03Eric Fiselier2015-05-271-2/+5
| | | | llvm-svn: 238273
* Fix race condition in thread test.Eric Fiselier2015-05-191-8/+25
| | | | llvm-svn: 237745
* Fix race conditions in test class used throughout the std::thread tests.Eric Fiselier2015-04-0210-15/+34
| | | | | | | | | | | 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
* [libcxx] Fix bug in shared_timed_mutex that could cause a program to hang.Eric Fiselier2015-04-021-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The summary of the bug, provided by Stephan T. Lavavej: In shared_timed_mutex::try_lock_until() (line 195 in 3.6.0), you need to deliver a notification. The scenario is: * There are N threads holding the shared lock. * One thread calls try_lock_until() to attempt to acquire the exclusive lock. It sets the "I want to write" bool/bit, then waits for the N readers to drain away. * K more threads attempt to acquire the shared lock, but they notice that someone said "I want to write", so they block on a condition_variable. * At least one of the N readers is stubborn and doesn't release the shared lock. * The wannabe-writer times out, gives up, and unsets the "I want to write" bool/bit. At this point, a notification (it needs to be notify_all) must be delivered to the condition_variable that the K wannabe-readers are waiting on. Otherwise, they can block forever without waking up. Reviewers: mclow.lists, jyasskin Reviewed By: jyasskin Subscribers: jyasskin, cfe-commits Differential Revision: http://reviews.llvm.org/D8796 llvm-svn: 233944
* Fix PR23041. Use lock_shared() as opposed to lock() in shared_lock test.Eric Fiselier2015-03-271-1/+1
| | | | llvm-svn: 233367
* Use generic feature name for sanitizers that replace new and deleteEric Fiselier2015-03-101-1/+1
| | | | llvm-svn: 231841
* libc++ tests: wait_until.pass test sporadically fails (bug 21998)Eric Fiselier2015-02-112-194/+258
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Hello Howard, While running the libc++ tests on our ARM boards, we encounter sporadic failures of the two tests: test/std/thread/futures/futures.shared_future/wait_until.pass.cpp test/std/thread/futures/futures.unique_future/wait_until.pass.cpp The worker thread might not finish yet when the main thread checks its result. I filed the bug 21998 for this case: http://llvm.org/bugs/show_bug.cgi?id=21998 Would you be able to review this please? Thank you. Oleg Reviewers: howard.hinnant, mclow.lists, danalbert, jroelofs, EricWF Reviewed By: jroelofs, EricWF Subscribers: EricWF, mclow.lists, aemerson, llvm-commits Differential Revision: http://reviews.llvm.org/D6750 llvm-svn: 228783
OpenPOWER on IntegriCloud