This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug linuxthreads/2948] New: Hang on exit if pthread_key_delete called after pthread_onexit_process


There is an obscure bug in linuxthreads.  I can recreate it under the following
conditions:

* gcc is configured without TLS support.

* The program is linked fully statically.

* The standard malloc is overridden.

* The program is linked against -lstdc++ (or -lsupc++).

Under this set of assumptions, the global destructor in
libstdc++/libsupc++/eh_globals.cc will be run after pthread_onexit_process is
run.  The global destructor will call pthread_key_delete.  pthread_key_delete
will attempt to contact the manager thread.  The manager thread will have
already exited.

The effect is that the program hangs after calling exit.

Now, to take the assumptions one by one:

* If gcc is configured with TLS support, then it uses __thread rather than
pthread_key_create/pthread_key_delete, so the program works.

* If the program is not linked fully statically, then -lpthread is linked after
-lstdc++, so its constructor runs first and its destructor runs last, so the
program works.

* malloc is called before global constructors are run, and the standard malloc
calls pthread_initialize the first time it is run, so if the standard malloc is
not overridden, then the program works.

* If the program is not linked against -lstdc++, then the eh_globals.cc
constructor is not run, so the destructor is not run, and the program works.

Is it worth fixing such an obscure case?  I don't know.  It happened to me, and
the patch is simple.

I will attach the test case and the patch.

-- 
           Summary: Hang on exit if pthread_key_delete called after
                    pthread_onexit_process
           Product: glibc
           Version: 2.3.2
            Status: NEW
          Severity: normal
          Priority: P2
         Component: linuxthreads
        AssignedTo: drow at false dot org
        ReportedBy: ian at airs dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=2948

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]