From -1959528223263783375
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc772,5ca55e7ece19bbaa,start
X-Google-Attributes: gidfc772,public
X-Google-Thread: f78e5,5ca55e7ece19bbaa,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-06-22 19:21:38 PST
Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.mel.connect.com.au!news.unimelb.edu.au!bounce-back
From: bgreen@nas.nasa.gov (Bryan Green)
Newsgroups: comp.std.c++,comp.lang.c++.moderated
Subject: standardize C++ behavior regarding dlopen()/dlclose()?
Date: 23 Jun 01 02:21:00 GMT
Organization: http://groups.google.com/
Lines: 60
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
Message-ID: <6faaf36e.0106212009.afe2d51@posting.google.com>
NNTP-Posting-Host: murlibobo.cs.mu.oz.au
X-Trace: ariel.ucs.unimelb.edu.au 993262897 1451 128.250.37.153 (23 Jun 2001 02:21:37 GMT)
X-Complaints-To: news@news.unimelb.edu.au
NNTP-Posting-Date: 23 Jun 2001 02:21:37 GMT
X-Original-Date: 22 Jun 2001 12:58:15 -0400
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
	iQBVAwUAOzN5GkHMCo9UcraBAQHRtgH8D4+8nJGKTrlhDE/7lBrUfwZw/R9DJA0P
	zAh5F9PqRq9emIglqps46tzAuuVcY9+edFutD9v9+3GXlKJDZsyHTw==
	=tAN7
X-WARNING-TO-MODERATORS: This article has been processed and
    accepted using a cryptographic program by the moderator
    of comp.lang.c++.moderated. Its content must not be changed or it
    will be automatically cancelled. If you don't like the
    article or its crossposting, return it to the submitter. 
    (You can delete this message if you are the last
    moderator to see it.)
X-Approved-For-Group: kuehl@fmi.uni-konstanz.de comp.lang.c++.moderated
X-Auth: PGPMoose V1.1 PGP comp.std.c++
	iQBFAgUAOzP9FeEDnX0m9pzZAQGkmAF/XZ4UDhDLh25MuuaH7eHyUmj9gJ9vG77R
	sPabVuon0dkTjya8pbvUnMMLZ8cHxs2Y
	=JZTO
Xref: archiver1.google.com comp.std.c++:6263 comp.lang.c++.moderated:20996

It seems that I'm not alone in running into trouble with the behavior
of C++ in "plugins" loaded with dlopen() calls.  Since C++ is a
language for large systems, and the use of plugins is becoming a
common approach to large system design, it seems like standard C++
should be able to "play friendly" with plugins.

I'm aware of two problems:

1) Use of static objects in a plugin.
2) Use of RTTI type_info and dynamic_cast in plugins.

1) static objects
Since the standard states that destructors for static objects are
called after a program exits, the standard effectively makes the
developer choose between a) not using static objects in a plugin, or
b) never calling dlclose() on the plugin.
But consider what a plugin developer would expect the behavior to be. 
If you are expecting your plugin to be unloaded as well as loaded,
then you expect your destructors to be called when the plugin is
unloaded, in the opposite order in which they were constructed when
the plugin was loaded.  The requirement that some global order with
respect to the application as a whole be maintained just doesnt make
sense in this context.  Shouldn't the scope for
construction/destruction be a library-scope, as opposed to
application-scope?
Applying a library-scope would not change the standard behavior as
currently defined for applications, but would make C++ behave properly
in a component (plugin) architecture.

2) RTTI
If two plugins share an abstract class by which they communicate, say
class T, shouldn't each module have a comparable definition of
'typeid(T)'? (assuming T has implementation details in a shared
library they each link against, or it is purely abstract and lives
only in a header file.)
That is, if one plugin passes a pointer 'p' of type T to a second
plugin, the second plugin should be able to successfully perform the
test
'typeid(*p) == typeid(T)'.

While this has worked for me so far with g++ and Irix CC, this now
fails with g++ 3.0.  Is this a bug?  I hope so.  It could be that my
configuration is screwed up somehow.  My question is: _should_ this be
a bug?
If this is not a C++ standardization issue, in what general forum
should this issue be addressed?  (My fear is that someone will say,
its not a standard-C++ issue, so you're out of luck!)  Is it a
question of C++ ABI standardization?

Thanks,
-bryan

      [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]


