I don't know if the bug report here is correct, but on the libc mailing list I was told to report a bug to the distro bug tracker rather then to the g++ bug tracker. Attached are two files: 1. libtest.cpp 2. test_dlopen.cpp libtest.cpp is my test library, and test_dlopen is the executable which loads the library (or any other if argc > 1), and closes it again. Problem description: Compile the test library with g++ (version 4.5*) and the executable with any g++ (doesn't seem to affect anything). Now execute test_dlopen. The output should display the libraries resident in memory after dlopen-ing libtest.so. Then it displays the return-value of dlclose libtest.so. Then once again the libraries resident in memory. And finally once again the return value of dlclose libtest.so (which should be definetly -1, since we've already closed the library, so the reference counter as stated in the man page drops to zero and any subsequent call should fail) What I see when compiling with g++ 4.5 is that the library is loaded correctly, but I'm unable to unload it again. It just does not work. Compiling the libtest.cpp with g++ 4.4.5 it works as expected. The test library is just a very very simple test-case with no real use. But it reduces the error to a simple library. Closing also fails for libboost-regex.so, libboost-date_time.so and other. Correct behaviour can be seen for libboost_thread.so. I hope the bug is clear. The bug appeared for me, when I tried my real-world libraries to reload, and I realized that it was not possible anymore. So for me this is a real blocker, since I recompile frequently my libraries at work and need to reload them without quitting my application (unfortunately closed source work, so no I cannot show the real example, but the simple example should be enough I guess). Reproducible: Always Steps to Reproduce:
Created attachment 259291 [details] Library source file (see in the file for the compile command)
Created attachment 259293 [details] Executable source code (see in the file for compile command)
Paste your emerge --info to let us see your environment. Do you verify that this happened only after upgrading to 4.5.x compilers?
Created attachment 259522 [details] emerge --info
The first time I realized it was with gcc-4.5.1 (unfortunately I've never tried with gcc-4.5.0) Currently I have gcc-4.4.5 and gcc-4.5.2. When I compile it with gcc-4.4.5 it works fine. Compiling it with gcc-4.5.2 creates me an unloadable library. Additionally I should say, that I'm not the only one who can reproduce this bug. As mentioned I was writing first to the libc mailinglist, and there Ángel González pointed out that it seems to be a problem with gcc (I thought it was glibc in the first place). Here the URL: http://thread.gmane.org/gmane.comp.lib.glibc.user/796/focus=799
POSIX does not require that dlclose() actually unload the module: http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlclose.html that said, your test case unloads things w/gcc-4.8+ for reference, here's the thread you posted using the glibc archives: https://sourceware.org/ml/libc-help/2010-12/msg00003.html