forked from OSchip/llvm-project
[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
This commit is contained in:
parent
e85506b6e0
commit
1f077f6b2b
|
@ -46,14 +46,17 @@ thread::~thread()
|
||||||
void
|
void
|
||||||
thread::join()
|
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
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
if (ec)
|
if (ec)
|
||||||
throw system_error(error_code(ec, system_category()), "thread::join failed");
|
throw system_error(error_code(ec, system_category()), "thread::join failed");
|
||||||
#else
|
|
||||||
(void)ec;
|
|
||||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||||
__t_ = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue