[libcxx-dev] __libcpp_thread_id_equal issue (affecting FreeBSD)

Ed Maste via libcxx-dev libcxx-dev at lists.llvm.org
Tue Jul 30 18:57:42 PDT 2019

We just had a FreeBSD bug submitted for a failure arising from
libc++'s use of pthread_equal.

FreeBSD's pthread_equal stub implementation (used in non-threaded
programs) returns true unconditionally, since a non-threaded program
cannot have two different threads. However, std::thread::id defines a
special value that should not equal any real thread, and this is may
be passed to pthread_equal. See FreeBSD PR 239550 for more details,
and PR 239038 for the user-facing issue that prompted this.


Now the most expedient fix is probably for us to make pthread_equal
somewhat less of a stub, but for correctness it seems
__libcpp_thread_id_equal would need to check for libc++'s special
value before calling pthread_equal.

More information about the libcxx-dev mailing list