If the vtable is functioning for normal virtual functions, why wouldn't it
also work for a virtual destructor? Destructors are not magic; they are
merely functions that get called just before memory is released. RTTI, a
common culprit in dlopen issues, doesn't get involved here.
Right. A more important question to ask is if static
constructors/destructors get properly executed, including the framework
necessary to support C++ exceptions. The C++ exception issue is significant
Hi,
My experience with C++/plugins verifies that static constructors
and destructors are invoked upon plug-in loading -- I often use static
ctors/dtors to perform additional registering of functions with internal
data structures upon dlopening. (compilers used: g++-3.3, 3.4, 4.0, 4.2
on FreeBSD, linux, darwin). I rely on static ctors/dtors to do all work
related to resource management.
since usually the framework is set up by the original program and if the
plugin does not properly mesh into it then there is a problem. There may
also be a problem if the program is written and linked as a C program but the
plugin is C++.
It shouldn't be too hard to set up an experiment or test case using C++
exceptions. I don't have an answer for this since an exception that
escapes past main() usually results in an abort trap, skipping all
exit-time cleanup code. Plugins are cleanly unloaded when a program exits
normally. I don't know how to catch an exception outside of main, i.e.
one thrown and uncaught during statics.
I'm not sure a C++ plug-in would work in C, but if you had a function for
cleaning up resources (something likely to appear in a dtor), you could
register a cleanup function with atexit().
Fang
David Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
http://www.csl.cornell.edu/~fang/
-- (2400 baud? Netscape 3.0?? lynx??? No problem!)
_______________________________________________
http://lists.gnu.org/mailman/listinfo/libtool