Bug 2377 - Deadlock between dlclose and c++ exception/unwind
Summary: Deadlock between dlclose and c++ exception/unwind
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P1 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-21 16:52 UTC by Steven Munroe
Modified: 2018-04-19 13:54 UTC (History)
2 users (show)

See Also:
Host: powerpc64-linux
Target: powerpc-linux
Build: powerpc-linux
Last reconfirmed:
fweimer: security-


Attachments
dlclose/exception testcase (2.58 KB, application/x-gzip)
2006-02-21 16:55 UTC, Steven Munroe
Details
Hand built back trace of the two threads after the hang. (3.30 KB, text/plain)
2006-02-21 17:00 UTC, Steven Munroe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Munroe 2006-02-21 16:52:41 UTC
In this case an application is calling a library via dlopen/dlsym/dlclose. This
library created a service thread that it needs to terminate when dlclose is
called. But if the service thread takes an exception after the call to dlclose
and the libraries call to pthread_join then the service thread will hang in the
unwind code and the join will never complete.
Comment 1 Steven Munroe 2006-02-21 16:55:32 UTC
Created attachment 879 [details]
dlclose/exception testcase

Untar this file and cd in the dllock_bug directory. Then run "make". This will
build and run the testcase.
Comment 2 Steven Munroe 2006-02-21 17:00:47 UTC
Created attachment 880 [details]
Hand built back trace of the two threads after the hang.

gdb does not give a useful back trace on powerpc fo this condition. So the
attached text file contains a handbuilt backtrace for the both threads.
Comment 3 Steven Munroe 2006-02-21 17:02:40 UTC
Example test case log:

parent   main:        called dlopen
parent   main:        calling dlsym for lib_func
parent   main:        calling lib_func
parent   lib_func:    arg1=test string
parent   lib_func:    thread created, rc=0
parent   main:        back, sleep(2)...
child    run_it:      new thread
child    run_it:      sleep(3)...
parent   main:        calling dlclose
parent   fini_Lib:    calling pthread_join
child    run_it:      awake again
child    run_it:      throw (this might hang)
Comment 4 Steven Munroe 2006-02-21 17:11:13 UTC
This testcase hangs on all the systems I have tested so far. Including;
powerpc and powerpc64, gcc-3.3.3/glibc-2.3.3, gcc-3.4.4/glibc-2.3.4, and
gcc-4.1.0/glibc-trunk.

I have try this on i686 gcc-3.3.3/glibc-2.3.3 and see the same failure there.

I suspect this general problem involving dl-close and g++ exception/unwind
processing.
Comment 5 Ryan S. Arnold 2006-03-20 22:30:08 UTC
I experienced the same problems on x86:

Target: i486-linux-gnu
gcc-4.0.3/glibc-2.3.5

I'll test on x86-64 if I can find some hardware lying around.
Comment 6 Ryan S. Arnold 2006-03-21 20:36:19 UTC
I tested this on x86-64 and it fails there as well.

Target: x86-64
gcc-4.0.1/glibc-2.3.5
Comment 7 Ulrich Drepper 2006-05-02 22:02:15 UTC
Nothing related to C++, exceptions, and dlopen can be critical.
Comment 8 Andreas Schwab 2010-09-02 15:52:24 UTC
Appears to work fine in 2.12.