diff options
| author | Asiri Rathnayake <asiri.rathnayake@arm.com> | 2016-06-03 08:45:26 +0000 |
|---|---|---|
| committer | Asiri Rathnayake <asiri.rathnayake@arm.com> | 2016-06-03 08:45:26 +0000 |
| commit | 1f077f6b2b9cf5b04890798e980fb438cc8f4873 (patch) | |
| tree | b8c7aab3455119b29c50726ce37a62a25010e588 /libcxx/src/thread.cpp | |
| parent | e85506b6e0de80276b8f1a778dd6156497681829 (diff) | |
| download | bcm5719-llvm-1f077f6b2b9cf5b04890798e980fb438cc8f4873.tar.gz bcm5719-llvm-1f077f6b2b9cf5b04890798e980fb438cc8f4873.zip | |
[libcxx] Fix thread join.pass.cpp segfault after r271475
Some pthread implementations do not like being called pthead_join()
with the pthread_t argument set to 0, and causes a segfault. This
patch fixes this issue by validating the pthread_t argument before
invoking pthread_join().
NFC.
Differential revision: http://reviews.llvm.org/D20929
Change-Id: Ief817c57bd0e1f43cbaa03061e02417d6a180c38
Reviewers: EricWF
llvm-svn: 271634
Diffstat (limited to 'libcxx/src/thread.cpp')
| -rw-r--r-- | libcxx/src/thread.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp index 406e71d2ac6..467402b6b42 100644 --- a/libcxx/src/thread.cpp +++ b/libcxx/src/thread.cpp @@ -46,14 +46,17 @@ thread::~thread() void thread::join() { - int ec = __libcpp_thread_join(&__t_); + int ec = EINVAL; + if (__t_ != 0) + { + ec = __libcpp_thread_join(&__t_); + if (ec == 0) + __t_ = 0; + } #ifndef _LIBCPP_NO_EXCEPTIONS if (ec) throw system_error(error_code(ec, system_category()), "thread::join failed"); -#else - (void)ec; #endif // _LIBCPP_NO_EXCEPTIONS - __t_ = 0; } void |

