[Bug dynamic-link/18457] New: pthread_join deadlock in library destructor
schwab@linux-m68k.org
sourceware-bugzilla@sourceware.org
Wed May 27 14:26:00 GMT 2015
https://sourceware.org/bugzilla/show_bug.cgi?id=18457
Bug ID: 18457
Summary: pthread_join deadlock in library destructor
Product: glibc
Version: 2.21
Status: NEW
Severity: normal
Priority: P2
Component: dynamic-link
Assignee: unassigned at sourceware dot org
Reporter: schwab@linux-m68k.org
CC: aoliva at redhat dot com
Blocks: 17090, 17620, 17621, 17628
Target Milestone: ---
A dlopen'd library that is unloaded and calls pthread_join in the destructor
causes a deadlock while waiting for the child to finish.
$ cat pthread-join.c
#include <dlfcn.h>
int
main (void)
{
void *f = dlopen ("pthread-join-test.so", RTLD_NOW | RTLD_GLOBAL);
if (f) dlclose (f);
}
$ cat pthread-join-test.c
#include <stdio.h>
#include <pthread.h>
static pthread_t th;
static int running = 1;
static void *
test_run (void *p)
{
while (running)
fprintf (stderr, "XXX test_run\n");
fprintf (stderr, "XXX test_run FINISHED\n");
return NULL;
}
static void __attribute__ ((constructor))
do_init (void)
{
pthread_create (&th, NULL, test_run, NULL);
}
static void __attribute__ ((destructor))
do_end (void)
{
running = 0;
fprintf (stderr, "thread_join...\n");
pthread_join (th, NULL);
fprintf (stderr, "thread_join DONE\n");
}
$ gcc -fPIC -shared pthread-join-test.c -lpthread -o pthread-join-test.so
$ gcc pthread-join.c -lpthread -ldl -Wl,-path=. -o pthread-join
$ ./pthread-join
thread_join...
XXX test_run FINISHED
This was broken by f8aeae3 ("Fix DTV race, assert, DTV_SURPLUS Static TLS
limit, and nptl_db garbage").
Referenced Bugs:
https://sourceware.org/bugzilla/show_bug.cgi?id=17090
[Bug 17090] Assertion failure (map->l_tls_modid == cnt) when dlopen()ing
initial-exec TLS shared objects under certain circumstances
https://sourceware.org/bugzilla/show_bug.cgi?id=17620
[Bug 17620] DTV_SURPLUS limits loading of Static TLS-requiring modules in
multi-threaded programs
https://sourceware.org/bugzilla/show_bug.cgi?id=17621
[Bug 17621] DTV update for Static TLS dlopened modules is racy
https://sourceware.org/bugzilla/show_bug.cgi?id=17628
[Bug 17628] nptl_db's td_thr_tls* don't check DTV generation
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list