Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* dlopen/dlclose & C++ (DEC UNIX)
@ 1996-03-25  5:00 ccrlphr
  1996-03-27  5:00 ` Alan H. Martin
  0 siblings, 1 reply; 2+ messages in thread
From: ccrlphr @ 1996-03-25  5:00 UTC (permalink / raw)



I got a problem while using the dynamic loading with C++ (DEC CXX 5.0). 
I wrote a app which defines an interface == class within a header file
and lets you dynamically load libraries with this interface within the 
run of the prog, e.g.:

        .......... file interface.hxx ............

        struct interface {
                virtual  void anyfunc() { /* default impl */ }
                virtual ~interface()    {}
        };

        .......... file dynalib.hxx ................

        #include "interface.hxx"
        struct dynalib: interface {
                void anyfunc()   { /* implementation */ }
                virtual ~dynalib {}
                dynalib(... )    { ... }
        };

        extern "C" interface *loaderFunc( ... ) {
                return new dynalib( ... );
        }

each of the shared libs must declare a function <loaderFunc> which gets mapped
with <dlsym> after loading the lib with <dlopen>. All this stuff works and I can
call any function of the object == shared lib ... My problem starts if I don't need 
the lib any longer and want to get the memory back using <dlclose>. I delete all
objects from the <dynalib> and expected to have no more references into the library
so I call <dlclose>. I get no error back with <dlerror> and can continue the app
w/o problems - but if it should finish it crashes in <__fini_cleanup> with an
"invalid symbol descriptor ... for symbol ... " as argument. I guess it tries to 
call a cleanup function within the shared lib which is no longer in the memory. 

This generates the question if this is
        a) a general problem between C++ and the dl-library
        b) a problem between DEC CXX (V5.0) and the dl-library
        c) a problem on DEC UNIX (osf/1 V.3.2C)
        d) a problem of misusage
        e) nothing of the above

I guess it's b) or c) because I had no problems with the same code on sparc/CC. 
BTW, does anybody knows a workaround ?? (except "not calling <dlopen>")


--
+++ Steffen Ullrich +++ ccrlphr@xensei.com +++ http://www.xensei.com/users/ccrlphr/ +++



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dlopen/dlclose & C++ (DEC UNIX)
  1996-03-25  5:00 dlopen/dlclose & C++ (DEC UNIX) ccrlphr
@ 1996-03-27  5:00 ` Alan H. Martin
  0 siblings, 0 replies; 2+ messages in thread
From: Alan H. Martin @ 1996-03-27  5:00 UTC (permalink / raw)


In article <4j6q8e$ucf@xensei3.xensei.com> ccrlphr@xensei.com writes:
>I got a problem while using the dynamic loading with C++ (DEC CXX 5.0). 
>I wrote a app which defines an interface == class within a header file
>and lets you dynamically load libraries with this interface within the 
>run of the prog, e.g.:

Cool.


>...  My problem starts if I don't need the lib any longer and want to get the
>memory back using <dlclose>.  ...

The file /usr/lib/cmplrs/cxx/DECCXX500.release-notes states on pp. 1-10 and
1-11:

"
        1.3.3 Current Restrictions

              This section contains usage notes and known problems with
              DEC C++ Version 5.0.
...
              o  Static destructors in dynamically loaded DEC C++ shared
                 libraries are not invoked if the DEC OSF/1 Alpha library
                 routine dlclose(3) is used to dynamically unload the C++
                 shared libraries. Furthermore, the main program fails
                 when exiting because it attempts to call the destructors
                 in the unloaded shared libraries.
"

Sorry about that.


>This generates the question if this is
>        a) a general problem between C++ and the dl-library
>        b) a problem between DEC CXX (V5.0) and the dl-library
>        c) a problem on DEC UNIX (osf/1 V.3.2C)
>        d) a problem of misusage
>        e) nothing of the above

It's a day-one design flaw in the C++ runtime support code which executes
static object destructors upon program exit (and dlclose).

The problem is fixed in DEC C++/Alpha/Unix V5.3, scheduled to ship on CDrom on
12-Apr-96.


>BTW, does anybody knows a workaround ?? (except "not calling <dlopen>")

Will disabling the dlclose calls for a few more weeks suffice?
				/AHM/THX
-- 
Alan Howard Martin				AMartin@TLE.ENet.DEC.Com



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-03-27  5:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-03-25  5:00 dlopen/dlclose & C++ (DEC UNIX) ccrlphr
1996-03-27  5:00 ` Alan H. Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox