[Bug 1450355] Re: statically linking libpthread is problematic

2015-04-30 Thread junyer
Note that the third case worked because the use of `-Wl,--whole-archive -lpthread -Wl,--no-whole-archive' is a workaround that evidently results in the TLS (Thread-Local Storage) being initialised properly. The root cause of this bug is currently uncertain, but

[Bug 1450355] Re: statically linking libpthread is problematic

2015-04-30 Thread junyer
junyer@whalre:~$ g++ -Wall -Werror foo.cc -o foo -lpthread junyer@whalre:~$ ./foo foo: pthread_rwlock_init(lock, NULL): 0 foo: pthread_rwlock_wrlock(lock): 0 foo: pthread_rwlock_unlock(lock): 0 foo: pthread_rwlock_wrlock(lock): 0 foo: pthread_rwlock_unlock(lock): 0 foo:

[Bug 1450355] Re: statically linking libpthread is problematic

2015-04-30 Thread junyer
Note that the second case hung and thus required me to hit Ctrl-C. The proximate cause seems to be that the TID (Thread ID) in the TLS (Thread-Local Storage) is not initialised properly: 1. The first pthread_rwlock_wrlock() call sets __writer to the TID, which is 0. 2. The first