Operating System - Linux
1752795 Members
6494 Online
108789 Solutions
New Discussion юеВ

Re: Shared library memory corruption and apache

 
Chris J_1
Occasional Contributor

Shared library memory corruption and apache

In an apache module that I build as a shared library I have a static structure and a static pointer pointing to it.

Immediately after apache executes shl_load, the memory address for the pointer holds 0 on some compiles of the shared library, and the memory address of the structure on other compiles. The difference between my compilations is the presence of the -g flag when creating the object files. When I compile using -g, the pointer holds the correct value, when I compile without it, the pointer holds 0. The behavior of whether the pointer has the correct value seems to be related to the size of the shared library as changing the length of strings or adding new functions to try and debug causes the problem to dissapear (I assume it is just moving to another location that I haven't noticed yet).

Has anyone experienced this behavior before or have any ideas about what is causing the pointer value to change.

I am running on HP-UX B.11.00 64bit but the library is compiled for 32bit.

Object files are compiled using cc using the following flags:

-O2 -Ae -z +z +Ofastaccess +ESlit +Oprocelim +DS2.0 +DA2.0

And linked using ld with these flags

+s -b -ashared -L/usr/lib -ldld -lnsl -lm -lc -L/opt/openldap/lib -lldap -L/opt/MDW/lib -lclntsh-9.0 -lfileman -lMagick -L/opt/apache.RISC_2/lib -lexpat -lapr-0 -laprutil-0 -lcurl

Note that I've trimmed defines and include search directories that I don't believe are relevant, they can be found at the end of this message.

Thanks for any advice as to what could be the cause of this behavior.

Chris Johnson




-DHPUX -DSLXMX_ENABLE -DSLTS_ENABLE -D_REENTRANT -DMDW_SCHEMAS -DSPORTS -DBRG -DCALENDAR -DDYNAPUB -DTASKTRACK -DCLASSIFIEDS -DDATA_ENTRY -DTRANSIT -DDEMOGRAPHICS -DORG -DELECTIONS -DECOMMERCE -DTEMPLATE -DATL -DFMS -DMM -DREPORTING -DCARTRIDGE -DAPACHE -DAUTH_LDAP -I/var/spool/software/src/fileman -I/u01/app/oracle/product/9.2.0/rdbms/demo -I/u01/app/oracle/product/9.2.0/rdbms/public -I/u01/app/oracle/product/9.2.0/precomp/public -I/opt/MDW/include -I/opt/openldap/include -I/opt/apache.RISC_2/include -I/opt/openldap/include -I/opt/magick/include
2 REPLIES 2
Dennis Handly
Acclaimed Contributor

Re: Shared library memory corruption and apache

Can you shl_load your lib from a smaller driver program and debug that?
Chris J_1
Occasional Contributor

Re: Shared library memory corruption and apache

Dennis,

Thanks for the advice, I'll try doing that to see if I can narrow down what the actual problem is. It may take me a while to get the stub done as I'm not well versed in writing programs that use shl_load and my first few attempts so far have run into unsatisfied symbol problems. I'm sure it will just be a matter of getting all of the correct things loaded (or preloaded) in the right order.

Chris