Author: asiri Date: Fri Jun 3 03:45:26 2016 New Revision: 271634 URL: http://llvm.org/viewvc/llvm-project?rev=271634&view=rev Log: [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 Modified: libcxx/trunk/src/thread.cpp Modified: libcxx/trunk/src/thread.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=271634&r1=271633&r2=271634&view=diff ============================================================================== --- libcxx/trunk/src/thread.cpp (original) +++ libcxx/trunk/src/thread.cpp Fri Jun 3 03:45:26 2016 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits