This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
Re: Bug in pthread_exit()
- To: glibc-linux at ricardo dot ecn dot wfu dot edu
- Subject: Re: Bug in pthread_exit()
- From: Kaz Kylheku <kaz at ashi dot footprints dot net>
- Date: Thu, 16 Dec 1999 10:55:58 -0800 (PST)
- Reply-To: glibc-linux at ricardo dot ecn dot wfu dot edu
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.