This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20237] New: Problem with order of destruction in shared object.
- From: "james dot kanze at free dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Feb 2005 18:57:19 -0000
- Subject: [Bug c++/20237] New: Problem with order of destruction in shared object.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Not sure if this can really be considered a bug, it
certainly violates the C++ standard, but since I'm
using extensions (e.g. dlopen, dlclose)...
The problem is simple: in the main module, I have
an std::map< std::string, Base* > at namespace scope,
which is getting constructed before main is entered.
Sometime later, I load a shared object, using dlopen;
the shared object has an object at namespace scope
which derives from Base. The constructor of Base
enroles the object in the map, and the destructor
removes it.
A rather common idiom, I would have thought. Regretfully,
the std::map is destructed before the derived object.
If someone wants to look into this, I should be able
to provide a small test program; I won't bother to
try and isolate it further, however, if you take the
position that I'm using a non-supported extension,
and that it is my problem. (I've a simply work-around:
I allocate the map dynamically with a sort of singleton
idiom, and never delete it, so it is never destructed.)
--
Summary: Problem with order of destruction in shared object.
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: james dot kanze at free dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20237