[Bug c++/13227] New: [3.4 Regression] dlclose() causes destruction of global objects in ALL shared C++ libraries.

carlo at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Nov 29 01:03:00 GMT 2003


This is a regression from g++ 3.3.x and earlier 3.4 CVS versions.

A call to dlclose() for a previously loaded
shared library closes ALL shared libraries
and destructs all global object in the process.

Very serious bug imho.  In previous versions
(g++-3.1, g++-3.1.1 and g++-3.2) even the standard
streams were closed as a result of a call to
dlclose() - I didn't check yet if that is now the
case too.

HOW TO REPRODUCE

I wrote a little test case.
Please download the tar ball, untar
and run 'make' in the resulting 
directory.

This was tested on i686-pc-linux-gnu
with CVS binutils 2.14.90 20031118 installed.

Using g++ 3.3.2:

~/c++/g++.bugs/bug15>make
g++-3.3.2 -I. -shared -fpic libA.cc -Wl,-soname,libA.so.0 -o libA.so.0.0.0
ln -sf libA.so.0.0.0 libA.so.0
ln -sf libA.so.0 libA.so
g++-3.3.2 -I. -shared -fpic libB.cc -Wl,-soname,libB.so.0 -o libB.so.0.0.0
ln -sf libB.so.0.0.0 libB.so.0
ln -sf libB.so.0 libB.so
g++-3.3.2 -I. main.cc -L. -lA -Wl,-rpath,./ -ldl -o main
~/c++/g++.bugs/bug15>main
Constructor of A
Constructor of B
Destructor of B
Program exitted successfully.
Destructor of A


And using a recent CVS version:

~/c++/g++.bugs/bug15>make
g++-cvs-3.4 -I. -shared -fpic libA.cc -Wl,-soname,libA.so.0 -o libA.so.0.0.0
ln -sf libA.so.0.0.0 libA.so.0
ln -sf libA.so.0 libA.so
g++-cvs-3.4 -I. -shared -fpic libB.cc -Wl,-soname,libB.so.0 -o libB.so.0.0.0
ln -sf libB.so.0.0.0 libB.so.0
ln -sf libB.so.0 libB.so
g++-cvs-3.4 -I. main.cc -L. -lA -Wl,-rpath,./ -ldl -o main
~/c++/g++.bugs/bug15>main
Constructor of A
Constructor of B
Destructor of A
Destructor of B
'a' was destroyed before it should be.

-- 
           Summary: [3.4 Regression] dlclose() causes destruction of global
                    objects in ALL shared C++ libraries.
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: carlo at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13227



More information about the Gcc-bugs mailing list