This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: (glibc-2.0.7) c++ constructors and pthreads


   Date: 19 Oct 1998 07:50:25 -0700
   From: "David S. Miller" <davem@dm.cobaltmicro.com>

I'm replying to myself, I found some problems and now I have no idea
how it could ever have worked on Linux systems.

      Date: 18 Oct 1998 21:07:42 -0000
      From: Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>

      > 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

      That's strange, on the very first call, malloc() calls
      ptmalloc_init() via the initial special hooks, which in turn calls
      __pthread_initialize() if that symbol has been linked in.  Can you
      check why this is not working ?

   Thank you for pointing this out.

   It seems that even though libpthread has been brought in, at the time
   ptmalloc_init() is called, __pthread_initialize is not resolved in
   libc's GOT, it is still zero.  So at this point it could be a Sparc
   specific bug.  I'll investigate further.

However, I have no idea where the real __pthread_initialize even
exists.  I see the version in linuxthreads/pthread.c which has a name
without two preceeding underscores and is static and is given the
constructor attribute.

I also see the extern declaration in sysdeps/pthread/pthread.h and the
weak_extern()'s for it in sysdeps/pthread/libc-lock.h

But nowhere do I see an actual definition of this function.
I just did a "egrep __pthread_initialize `find . -type f`" on the
entire glibc-2.0.7pre6 tree and here is what I came up with:

./ChangeLog:    (__pthread_initialize): New macro, work around assumption of pthreads.
./ChangeLog:    (__pthread_initialize): New macro, work around assumption of pthreads.
./malloc/malloc.c:  if (__pthread_initialize != NULL)
./malloc/malloc.c:    __pthread_initialize();
./malloc/thread-m.h:#define __pthread_initialize ((void (*)(void))0)
./linuxthreads/sysdeps/pthread/pthread.h:extern void __pthread_initialize __P ((void));
./linuxthreads/sysdeps/pthread/libc-lock.h:weak_extern (__pthread_initialize)
./linuxthreads/sysdeps/pthread/libc-lock.h,v:weak_extern (__pthread_initialize)

I ask again, how is this supposed to work? :-)

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]