Operating System - Linux
1752421 Members
5913 Online
108788 Solutions
New Discussion юеВ

Re: c++ static global classes not constructed

 
Ryan Owen
New Member

c++ static global classes not constructed

I'm trying to internationalize our product for HP-UX 11i. I have everything building and working on some 11i systems, but others segfault when attempting to dereference a pointer to a static global c++ class instance. When I add a printf to the constructor of this class, I see it printed out on the systems where everything works, but not on the systems where it doesn't work. So it seems that the global class instance isn't being constructed on some systems.

I'm using GCC 4.0.2
libstdc++ is linked statically.
Here is my link command:
/usr/local/4.0.2/bin/gcc -o mcommon.o build_enhance.o load.o -lesmu -lesmsdk -lboost_regex -ldce -Wl,+n /usr/local/lib/libiconv.a /usr/lib/libdld.sl -lnsl -lsec -Wl,-a,archive_shared -lc -lm --L../../build/release/lib/hpux-hppa-11 -s -L/lib/hpux-hppa-11 -lstdc++

The global class instance in question is created in libesmsdk.a, which is an archive library created earlier in the build processes.

Any help is greatly appreciated!
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: c++ static global classes not constructed

First, I don't never, ever use no gcc on HP-UX so I am speaking from ignorance but ...

Compare the settings of the LD_PRELOAD environment variable on "good" and "bad" systems.

Ditto with "locale -a".

Ditto with patches especially those related to linker tools and ld.
If it ain't broke, I can fix that.
Harri Pasanen_1
Advisor

Re: c++ static global classes not constructed

The dynamic linker needs to be at a certain patch level. Compare the output of "what /usr/ccs/bin/ld" on machines where it works and where it does not work.
Ryan Owen
New Member

Re: c++ static global classes not constructed

I've found that patch PHSS_30968 is what makes the difference. What still doesn't make sense to me is that the objects that are not being constructed exist in statically linked libraries, not dynamic ones - so why would a patch to the dynamic linker make the difference??
A. Clay Stephenson
Acclaimed Contributor

Re: c++ static global classes not constructed

Because something has to invoke these constructors. There is probably a difference in the run-time startup routines.
You should also note that PHSS_33033 supercedes your patch and is marked "Critical" so it's probably a good idea to update to it.
If it ain't broke, I can fix that.