[PATCH] D20929: [libcxx] Fix join.pass.cpp segfault after r271475
Asiri Rathnayake via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 2 14:02:22 PDT 2016
rmaprath created this revision.
rmaprath added a reviewer: EricWF.
rmaprath added a subscriber: cfe-commits.
After r271475 [1], I'm seeing a segfault in `join.pass.cpp` on my system.
The test calls `std::thread::join()` twice and expects it to throw a system_error. It looks like my pthread implementation does not like being called {{pthread_join}} with the pthread_t argument set to zero, and decides to segfault. There are few easy ways to fix this, I've gone with the approach taken in `std::thread::deatch()` so there's more consistency.
[1] http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp?r1=271475&r2=271474&pathrev=271475
http://reviews.llvm.org/D20929
Files:
src/thread.cpp
Index: src/thread.cpp
===================================================================
--- src/thread.cpp
+++ src/thread.cpp
@@ -46,14 +46,17 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20929.59453.patch
Type: text/x-patch
Size: 573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160602/e9354fdb/attachment.bin>
More information about the cfe-commits
mailing list