static constructor from shared library not getting called on aix when loaded by Apache Web Server

static constructor from shared library not getting called on aix when loaded by Apache Web Server

Post by wap » Sat, 29 Apr 2000 04:00:00



All,

I have shared module A (e.g. mod_example.so) which gets
loaded by Apache Web Server 1.3.9 running on AIX 4.3. The
handler function of module A makes call to a function from module
B (lets say xyz.so, function is declared as extern "C" abc())
which makes call to ORB_init().

When web server loads the library it fails to call the
constructor for all static variables declared in orb lib, which
causes orb methods to fail. If I replace apache server and write
my own program which loads module A using dlopen() and calls the
handler function using dlsym() everything works fine.

I looked at apache web server code and found that for AIX
platform, web server includes os-aix-dso.c file in os.c file.
os-aix-dso file has implementation if dlopen() which calls load()
to load the shared library.  Since load does not initialise the
variable, I even changed it to loadAndInit() but no luck.

summary:

Apache(written in C) -> mod_example.so (written in C) -> xyz.so
(C++ file, has extern function which is declared as c function
using extern "C") -> ORB_init() (C++ shared library).

Any help on above issue will be greatly appreciated.

Thanks

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!

 
 
 

static constructor from shared library not getting called on aix when loaded by Apache Web Server

Post by wap » Sat, 29 Apr 2000 04:00:00


Upgrading to Apache Web Server 1.3.12 on AIX 4.3 resolved the
problem. What I notice is that for AIX 4.3 they are no longer
use os-aix-dso.c.  Also I compiled my apache server with xlC.

Thanks

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!

 
 
 

static constructor from shared library not getting called on aix when loaded by Apache Web Server

Post by barke.. » Mon, 01 May 2000 04:00:00


I too am having this problem.  A simple shared library that contains
a class with a static data member.  That static member does not get
constructed properly.  Are there any workarounds for this problem?  My
application crashes because initialization.

Thanks -

Ed



? All,
?
? I have shared module A (e.g. mod_example.so) which gets
? loaded by Apache Web Server 1.3.9 running on AIX 4.3. The
? handler function of module A makes call to a function from module
? B (lets say xyz.so, function is declared as extern ?C? abc())
? which makes call to ORB_init().
?
? When web server loads the library it fails to call the
? constructor for all static variables declared in orb lib, which
? causes orb methods to fail. If I replace apache server and write
? my own program which loads module A using dlopen() and calls the
? handler function using dlsym() everything works fine.
?
? I looked at apache web server code and found that for AIX
? platform, web server includes os-aix-dso.c file in os.c file.
? os-aix-dso file has implementation if dlopen() which calls load()
? to load the shared library.  Since load does not initialise the
? variable, I even changed it to loadAndInit() but no luck.
?
? summary:
?
? Apache(written in C) -? mod_example.so (written in C) -? xyz.so
? (C++ file, has extern function which is declared as c function
? using extern ?C?) -? ORB_init() (C++ shared library).
?
? Any help on above issue will be greatly appreciated.
?
? Thanks
?
? * Sent from RemarQ http://www.remarq.com The Internet's Discussion
Network *
? The fastest and easiest way to search and participate in Usenet -
Free!
?
?

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. Static constructors not called for C++ shared library

Apologies if this has been covered before, but I have searched through
the newsgroup and the IBM web site and come up dry.

I am porting a shared library written in C++ to AIX, which is loaded
using load(). If I build a test application under AIX 4.1 to call the
library, the static constructors for my library do not get called. If I
build my application under AIX 4.2, it works fine.

I am concerned by the description for load() which states that "If the
program calling the load subroutine was linked on 4.2 or a later
release, the load subroutine will call initialization routines...". I do
not control the calling app, which is built pre-4.2.

I found one reference to this topic in May '95 AIXpert, it says to use
makeC++SharedLib which I am already doing.

Any pointers or advice welcome.

Glenn Langford

2. ISDN h/w for SCO 5 ?

3. Problem: shared object loading runs constructor of a static object, but static linkage does not.

4. Syncmaster 191T and i810 problem

5. Constructors of static objects not called (VAC++5.0)

6. routing algorithm in FreeBSD TCP/IP

7. Q: constructor not called for global object in solaris shared lib

8. Installing problems

9. AIX shared libs with g++: global constructors not executed

10. static constructor calls

11. called from main or static constructor

12. Shared libs, C++, static constructor considerations

13. SOLVED: static variable class constructors in shared libs