Operating System - HP-UX
1833756 Members
2590 Online
110063 Solutions
New Discussion

static constructors in dlopen

 
lara
Advisor

static constructors in dlopen

Hi,

Does anyone know if there is a way to break in each of the static constructors called during dlopen() or destructors during dlclose() of a C++ library.
Currently, I am debugging a problem, where the program segfaults in dlclose() when I close the C++ shared library loaded through dlopen(). I suspect that there is a problem with the static destructors.
I have tried including the cpprt0.s stub suggested in some website and also tried using shl_load() instead of dlopen() and in both the cases it fails while closing.
Does anyone has faced a similar problem? If so can you let me know how to debug it.

Thanks
4 REPLIES 4
ranganath ramachandra
Esteemed Contributor

Re: static constructors in dlopen

make sure you link with aCC/g++ and not use the linker directly, when linking c++ objects (especially while building shared libraries).

what compiler and linker are you using ? is this a 32-bit or a 64-bit application ?
 
--
ranga
hp-ux 11i v3[i work for hpe]

Accept or Kudo

lara
Advisor

Re: static constructors in dlopen

Hi,

Yes, I compile with aCC and it's on 32bit platform

Thanks
ranganath ramachandra
Esteemed Contributor

Re: static constructors in dlopen

i remember one case of dlclose ending in a core dump, which was solved by the latest linker/loader patch, but i dont have the details.

by the way, you dont just compile with aCC, you also link with it with the "-b" option when building the shared library. cpprt0.s is not required with aCC (i think it may be relevant to either g++ or the obsolete cfront). aCC includes /opt/aCC/lib/shlrt0.o in the link line (and adds an initializer/terminator __shlInit with the +I linker option). however if your initializer is being called, you dont need to bother about all this, just try the latest linker/loader patch and let us know if the problem still exists.
 
--
ranga
hp-ux 11i v3[i work for hpe]

Accept or Kudo

ranganath ramachandra
Esteemed Contributor

Re: static constructors in dlopen

correction - cpprt0.o is linked in while building executables and shlrt0.o into shared libraries.

i am not very sure if this helps: "odump -slinit" will list the initializers of the shared library, perhaps you can proceed from here to set breakpoints.
 
--
ranga
hp-ux 11i v3[i work for hpe]

Accept or Kudo