Browse Source

libpthread: pthread_exit in static app. segfaults

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:
http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=e1f0b2cfa14b058ab033431b70428ccda8ec6ed0
For further detail see also glibc bug at:
http://sourceware.org/bugzilla/show_bug.cgi?id=12310

Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Cc: Vladimir Nikulichev  <v.nikulichev@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Filippo ARCIDIACONO 10 years ago
parent
commit
23691332c8
1 changed files with 6 additions and 0 deletions
  1. 6 0
      libpthread/nptl/pthread_exit.c

+ 6 - 0
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.
+ */
+PTHREAD_STATIC_FN_REQUIRE (pthread_create)