On 2014-05-26 02:31, Gabriele Giacone wrote:
$ wget
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1228201/+attachment/3831609/+files/thread.cpp
$ g++ thread.cpp -pthread -std=c++11 -o thread
$ ./thread
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not
permitted
Aborted
This happens because in gcc/src/libstdc++-v3/src/c++11/thread.cc,
thread::_M_start_thread throws EPERM if __gthread_active_p is false.
__gthread_active_p, implemented inline in bits/gthr-default.h, does
the following (simplified):
__gthrw2(__gthrw_(__pthread_key_create),
__pthread_key_create,
pthread_key_create)
# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create)
[...]
static inline int
__gthread_active_p (void)
{
static void *const __gthread_active_ptr
= __extension__ (void *) >HR_ACTIVE_PROXY;
return __gthread_active_ptr != 0;
}
so checks for the presence of __pthread_key_create to determine
whether threads are available, with a lengthy comment saying why that
symbol is checked when using the GNU C library.
Indeed, creating a simple extern "C" __pthread_key_create which just
calls pthread_key_create in the test case makes it run fine.
It looks like to me there are two solutions:
a) fix the GCC detection of threads on Hurd, so it uses only
pthread_key_create (or another internal symbol of Hurd's
libpthread)
b) fix pthread_key_create in Hurd's libpthread, changing it to
__pthread_key_create and declaring pthread_key_create as strong
alias, just like it is done in NPTL
IMHO most probably (b) is the most realistic and easy to do.
--
Pino Toscano
--
To UNSUBSCRIBE, email to debian-gcc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive:
https://lists.debian.org/dc34b7c80c0fac5d6550c9411521c...@pino.toscano.name