libc/libthread_xu - Fix segfault caused by libpthread used before initialised
authorMarkus Pfeiffer <markus.pfeiffer@morphism.de>
Mon, 18 Mar 2013 21:46:24 +0000 (21:46 +0000)
committerMarkus Pfeiffer <markus.pfeiffer@morphism.de>
Thu, 21 Mar 2013 23:43:56 +0000 (23:43 +0000)
commita809fd3908a7e5b67c1132990fcecf9eb355dc54
tree8ccc071e83484fabbcffba162ea609a1fa86d243
parentc3ab84cc4b098e768a5ab0e74ea571534875a455
libc/libthread_xu - Fix segfault caused by libpthread used before initialised

If a binary has libpthread as dependency and is linked against libintl,
or any other library that uses pthread locking primitives from libc
without depending on libpthread itself it can happen that functions
from libpthread are called before libpthread's constructor has been
called. This leads to a segfault.

This fix adds a weak symbold to libc, namely _pthread_init_early,
which is called from a libc constructor function and therefore makes
sure that libpthread is initialised early enough.

Thanks to Simon Schubert, Angelos Oikonomopoulos, and Sascha Wildner
for the support in debugging this.
lib/libc/gen/_pthread_stubs.c
lib/libthread_xu/thread/thr_init.c