(glibc-2.0.7) c++ constructors and pthreads

David S. Miller davem@dm.cobaltmicro.com
Sun Oct 18 10:09:00 GMT 1998


I have a crash case here for a program which has global c++
constructors and links against linuxthreads, one of the c++
constructors ends up calling malloc(), and this crashes because the
pthread constructor has not run yet and malloc() wants to setup it's
internal locks in the private area of the pthread_initial_thread.

This is deadly on machines such as Sparc which have to do
INIT_THREAD_SELF to initialize a global register to point to the
thread information block.

This looks rather nasty and I cannot think of a clean fix to make sure
pthread's constructor runs early enough in a guarenteed manner.

Any ideas?

Later,
David S. Miller
davem@dm.cobaltmicro.com



More information about the Libc-hacker mailing list