Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 351113 - >=sys-devel/gcc-4.5 - g++ creates unloadable libraries
Summary: >=sys-devel/gcc-4.5 - g++ creates unloadable libraries
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: High major (vote)
Assignee: Gentoo Toolchain Maintainers
URL: https://sourceware.org/ml/libc-help/2...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-08 12:58 UTC by Andreas Fink
Modified: 2015-10-03 01:16 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Library source file (see in the file for the compile command) (libtest.cpp,222 bytes, text/plain)
2011-01-08 12:59 UTC, Andreas Fink
Details
Executable source code (see in the file for compile command) (test_dlopen.c,1.57 KB, text/plain)
2011-01-08 12:59 UTC, Andreas Fink
Details
emerge --info (emerge.info,4.25 KB, text/plain)
2011-01-11 08:23 UTC, Andreas Fink
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Fink 2011-01-08 12:58:15 UTC
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:
Comment 1 Andreas Fink 2011-01-08 12:59:04 UTC
Created attachment 259291 [details]
Library source file (see in the file for the compile command)
Comment 2 Andreas Fink 2011-01-08 12:59:29 UTC
Created attachment 259293 [details]
Executable source code (see in the file for compile command)
Comment 3 Panagiotis Christopoulos (RETIRED) gentoo-dev 2011-01-11 07:53:58 UTC
Paste your emerge --info to let us see your environment. Do you verify that this happened only after upgrading to 4.5.x compilers?
Comment 4 Andreas Fink 2011-01-11 08:23:58 UTC
Created attachment 259522 [details]
emerge --info
Comment 5 Andreas Fink 2011-01-11 08:28:53 UTC
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
Comment 6 SpanKY gentoo-dev 2015-10-03 01:16:11 UTC
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