This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu 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: Bug in pthread_exit()



Hmm,

I thought -pthread should do all the necessary stuff, i.e. define
_REENTRANT and -lpthread????

Now I compiled my program again but added -lpthread and -D_REENTRANT to the
compiler flags
and it seems to work.....

I am totally missing something here......

Is it possible that memset() was using some wrong implementation because of
wrong compile flags, and therefore hanging?

I will test it later tonight or tomorrow morning....

K.D.


                                                                                                                                               
                    Kaz Kylheku                                                                                                                
                    <kaz@ashi.footprints.net>          To:     glibc-linux@ricardo.ecn.wfu.edu                                                 
                    Sent by:                           cc:                                                                                     
                    owner-glibc-linux@ricardo.e        Subject:     Re: Bug in pthread_exit()                                                  
                    cn.wfu.edu                                                                                                                 
                                                                                                                                               
                                                                                                                                               
                    12/16/99 06:55 PM                                                                                                          
                    Please respond to                                                                                                          
                    glibc-linux                                                                                                                
                                                                                                                                               
                                                                                                                                               




On Thu, 16 Dec 1999 kd@flaga.is wrote:

> Date: Thu, 16 Dec 1999 16:35:31 +0000
> From: kd@flaga.is
> Reply-To: glibc-linux@ricardo.ecn.wfu.edu
> To: glibc-linux@ricardo.ecn.wfu.edu
> Subject: Bug in pthread_exit()
>
>
> Hi,
>
> I have glibc-2.1.2 with Kaz patch (posted here a couple a days ago)
applied
> and my own clearing of the pthread_descr_struct in pthread_allocate_stack
()
> (in file manager.c)
> instead of the memset() function call (that does nothing but hang when
> called from pthread_allocate_stack)
>
> The kernel is 2.2.5 adapted for embedded target MPC823. The compiler is
> gcc2-95.2 (C and C++ frontends).
>
> pthread_exit has the following implementation:
>
> void weak_function pthread_exit(void* retval)
> {
>      exit(EXIT_SUCCESS);
> }

Hi K.D.!

You are looking at weaks.c, which contains stub versions of the threads
functions for non-threaded programs!!!

The *real* pthread_exit is a non-trivial function found in join.c.

> When exit(EXIT_SUCCESS) is called (because one thread is exiting and
calls
> pthread_exit()) the whole process is terminated, which is according to
the
> documentation of exit(3).
> But pthread_exit() should only terminate the thread that is exiting.

Right; but in a single threaded program, there is only one thread, so
pthread_exit is equivalent to exit().

So there is no problem. You just have to make sure you are building your
threaded program the right way: -D_REENTRANT on the compiler command line,
and
-lpthread to link in the threading library which will override the weaks
with
the real functions.





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