[git commit] libpthread: pthread_exit in static app. segfaults

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Thu Jul 4 09:25:17 UTC 2013

commit: http://git.uclibc.org/uClibc/commit/?id=23691332c8458adb469ad78051493ef0db434222
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Static applications that call pthread_exit on the main thread segfault.
This is because after a thread terminates __uClibc_main decrements
__nptl_nthreads which is only defined in pthread_create.
Therefore the right solution is to add a requirement to pthread_create
from pthread_exit.
This patch has been backported from glibc tree:
For further detail see also glibc bug at:

Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono at st.com>
Cc: Vladimir Nikulichev  <v.nikulichev at gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
 libpthread/nptl/pthread_exit.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/libpthread/nptl/pthread_exit.c b/libpthread/nptl/pthread_exit.c
index b37be7a..141ca75 100644
--- a/libpthread/nptl/pthread_exit.c
+++ b/libpthread/nptl/pthread_exit.c
@@ -29,3 +29,9 @@ __pthread_exit (void* value)
   __do_cancel ();
 strong_alias (__pthread_exit, pthread_exit)
+ * After a thread terminates, __uClibc_main decrements __nptl_nthreads
+ * defined in pthread_create.c.
+ */

More information about the uClibc-cvs mailing list