Operating System - Linux
1752313 Members
5660 Online
108786 Solutions
New Discussion юеВ

Cannot dlopen load module

 
Maruti
Advisor

Cannot dlopen load module

I have created a shared object 'TRIGGER.so' using COBOL 32-bit compiler on IA64 11.23. I have linked C objects, Oracle libraries & COBOL code in it with the entry point as TRIGGER.COB.

I am facing this error when I am linking libclntsh.so with TRIGGER.so

Load error : file 'TRIGGER.so'
error code: 198, pc=125, call=1, seg=0
198 Load failure (Cannot dlopen load module '/usr/lib/hpux32/libpthread.so.1' because it contains thread

PS 32-bit objects & libraries have been used everywhere.
13 REPLIES 13
Arunvijai_4
Honored Contributor

Re: Cannot dlopen load module

Hello,

Have you linked the module with -lpthread ?
If not, try to do so.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Maruti
Advisor

Re: Cannot dlopen load module

I have already tried with -lpthread option but am still getting the same error.

cob -z TRIGGER.COB /oracle/product/9.2/precomp/lib32/cobsqlintf.o /oracle/product/9.2/lib32/scorept.o /oracle/product/9.2/lib32/sscoreed.o /oracle/product/9.2/rdbms/lib32/kpudfo.o -L /oracle/product
/9.2/lib32/ -lclntsh -lpthread -lcurses -lm

While going thru documentation, I found:
"Use caution when building shared libraries with external library dependencies. Any library that contains Thread Local Storage (TLS) and uses static TLS model should not be used as a dependency. If a dependent library contains TLS, was built with static TLS model and it is not loaded during program startup (that is, not linked against the executable), the dynamic loader fails to perform the operation. You can use +tls=dynamic compiler option to re-compile the library to avoid errors."

I am doubting -lclntsh (Oracle Client Library) is having some connection with TLS.

-Maruti
Dennis Handly
Acclaimed Contributor

Re: Cannot dlopen load module

>I am facing this error when I am linking libclntsh.so with TRIGGER.so
>Load error : file 'TRIGGER.so'
>(Cannot dlopen load module '/usr/lib/hpux32/libpthread.so.1' because it contains thread

This was recently discussed:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1024963

>I am doubting -lclntsh (Oracle Client Library) is having some connection with TLS.
-Maruti

Your problem IS with libclntsh.so. It links with libpthread and it shouldn't do this.

You are dynamically loading your module. What is the name of the executable that is dynamically loading things? If that is compiled with libpthread, it will work. Or you can use LD_PRELOAD.
Maruti
Advisor

Re: Cannot dlopen load module

Dennis,

I have already gone through
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1024963
But the solution there isn't helping either.

>Your problem IS with libclntsh.so. It links with libpthread and it shouldn't do this.

Oracle Client Library libclntsh.so will definitely link to libpthread. I am pasting the "ldd" O/P here:
ldd /oracle/product/9.2/lib32/libclntsh.so.9.0
libwtc9.so => /oracle/product/9.2/lib32/libwtc9.so
librt.so.1 => /usr/lib/hpux32/librt.so.1
libnss_dns.so.1 => /usr/lib/hpux32/libnss_dns.so.1
libdl.so.1 => /usr/lib/hpux32/libdl.so.1
libm.so.1 => /usr/lib/hpux32/libm.so.1
libpthread.so.1 => /usr/lib/hpux32/libpthread.so.1
libCsup.so.1 => /usr/lib/hpux32/libCsup.so.1
libunwind.so.1 => /usr/lib/hpux32/libunwind.so.1
libdl.so.1 => /usr/lib/hpux32/libdl.so.1
libdl.so.1 => /usr/lib/hpux32/libdl.so.1
ibuca.so.1 => /usr/lib/hpux32/libuca.so.1

>You are dynamically loading your module. What is the name of the executable that is dynamically loading things? If that is compiled with libpthread, it will work. Or you can use LD_PRELOAD.

I have tried LD_PRELOAD option:
export LD_PRELOAD=/usr/lib/hpux32/libpthread.so.1
But then I started getting this error:
aCC runtime: Use of "-mt" must be consistent during both compilation and linking.
rts32: Error 115 encountered in critical run-time section

Then, I tried to recompile the COBOL codes with "-t" directive to make them multi-threaded. But still getting the same error. I also tried the other solution of applying HP-UX latest patches PHSS_34043 & PHSS_34441 to over-ride this problem. But after applying these patches, the LD_PRELOAD option has stopped working.

I am calling this shared object TRIGGER.so from a cobol code as the first step towards the execution of cobol code. I am not suposed to change the cobol run-time executable through which the code will be run.
Dennis Handly
Acclaimed Contributor

Re: Cannot dlopen load module

>I have tried LD_PRELOAD option:
export LD_PRELOAD=/usr/lib/hpux32/libpthread.so.1
But then I started getting this error:
aCC runtime: Use of "-mt" must be consistent during both compilation and linking.

This means you have some aC++ code, most likely in shared libs, that is not compiled with -mt.

>Then, I tried to recompile the COBOL codes with "-t" directive to make them multi-threaded.

The error message deals with aC++ sources, not COBOL.

>I also tried the other solution of applying HP-UX latest patches PHSS_34043 & PHSS_34441 to override this problem. But after applying these patches, the LD_PRELOAD option has stopped working.

This shouldn't change the issue. I don't see how LD_PRELOAD shouldn't work with them.

About the only other solution is to remove libpthread.so.1 from Oracle's libclntsh.so.

You do this by using "chatr +s enable libclntsh.so" and then creating an empty dummy libpthread.1 (compile an empty source to that shlib) and use SHLIB_PATH to point to it.
Maruti
Advisor

Re: Cannot dlopen load module

Hi Dennis,
Sorry for a delayed response to your solutions.

>This means you have some aC++ code, most likely in shared libs, that is not compiled with -mt.
This error was coming while using LD_PRELOAD option but before applying HP-UX latest patches PHSS_34043 & PHSS_34441. But as I have mentioned earlier, now LD_PRELOAD is not making any differences in execution.

>You do this by using "chatr +s enable libclntsh.so"
Can yu give me more information on this option?
Dennis Handly
Acclaimed Contributor

Re: Cannot dlopen load module

>>You do this by using "chatr +s enable libclntsh.so"

>Can you give me more information on this option?

Make a copy of this shlib, or make it writable to you.

Then use "chatr +s enable libclntsh.so". (At least you need to do that for PA. First use chatr libclntsh.so, to see if either LD_LIBRARY_PATH or SHLIB_PATH is enabled.)

Once enabled, you can use those env vars to point to a different and dummy libpthread so you can get it out of the way.
Maruti
Advisor

Re: Cannot dlopen load module

Dennis,

I tried chatr +s enable libclntsh.so.9.0 and it shwed same current & new values.
Then I created a dummy file with name libpthread.so.1 in a directory and set LD_LIBRARY_PATH to it. After doing so, I recreated libclntsh.so.9.0 but still I am getting same error.

/oracle/product/9.2/lib32 >chatr +s enable libclntsh.so.9.0
libclntsh.so.9.0:

current values:
32-bit ELF shared library
shared library dynamic path search:
LD_LIBRARY_PATH enabled first
SHLIB_PATH enabled second
embedded path enabled third /oracle/product/9.2/lib32
internal name:
libclntsh.so.9.0
shared library list:
libwtc9.so
librt.so.1
libnss_dns.so.1
libdl.so.1
libm.so.1
libpthread.so.1
libCsup.so.1
libunwind.so.1
shared vtable support disabled
explicit unloading enabled
segments:
index type address flags size
6 text 04000000 z---c- D (default)
7 data 40000000 ---m-- D (default)
kernel assisted branch prediction enabled
lazy swap allocation for dynamic segments disabled
nulptr references enabled
address space model: default
caliper dynamic instrumentation disabled
new values:
32-bit ELF shared library
shared library dynamic path search:
LD_LIBRARY_PATH enabled first
SHLIB_PATH enabled second
embedded path enabled third /oracle/product/9.2/lib32
internal name:
libclntsh.so.9.0
shared library list:
libwtc9.so
librt.so.1
libnss_dns.so.1
libdl.so.1
libm.so.1
libpthread.so.1
libCsup.so.1
libunwind.so.1
shared vtable support disabled
explicit unloading enabled
segments:
index type address flags size
6 text 04000000 z---c- D (default)
7 data 40000000 ---m-- D (default)
kernel assisted branch prediction enabled
lazy swap allocation for dynamic segments disabled
nulptr references enabled
address space model: default
caliper dynamic instrumentation disabled
Dennis Handly
Acclaimed Contributor

Re: Cannot dlopen load module

>I tried chatr +s enable libclntsh.so.9.0 and it showed same current & new values.

So you don't need to do that or make a copy.

>Then I created a dummy file with name libpthread.so.1 in a directory and set LD_LIBRARY_PATH to it.

A dummy shared lib must be created by the compiler and linker from an empty file.
$ touch empty.c
$ cc -b -o libpthread.so.1 empty.c

And remove any -lpthread or LD_PRELOAD with libpthread.