public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug dynamic-link/18457] New: pthread_join deadlock in library destructor
@ 2015-05-27 14:26 schwab@linux-m68k.org
  2015-05-27 15:59 ` [Bug dynamic-link/18457] " david.abdurachmanov at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: schwab@linux-m68k.org @ 2015-05-27 14:26 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-07-05 11:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27 14:26 [Bug dynamic-link/18457] New: pthread_join deadlock in library destructor schwab@linux-m68k.org
2015-05-27 15:59 ` [Bug dynamic-link/18457] " david.abdurachmanov at gmail dot com
2015-06-03  5:09 ` aoliva at sourceware dot org
2015-06-10 13:23 ` fweimer at redhat dot com
2015-07-02 16:11 ` carlos at redhat dot com
2015-07-06 21:13 ` aoliva at sourceware dot org
2015-07-06 23:14 ` schwab@linux-m68k.org
2015-07-24 13:44 ` cvs-commit at gcc dot gnu.org
2015-07-24 13:46 ` siddhesh at redhat dot com
2020-07-05 11:34 ` meave390 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).