Operating System - Linux
1748129 Members
3717 Online
108758 Solutions
New Discussion юеВ

Re: Threaded local storage ?

 
SOLVED
Go to solution
Leif Halvarsson_2
Honored Contributor

Threaded local storage ?


Hi,
One of our customers got a problem with an application, the error message (part of it) is below:
/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local Storage: /u10/test/testcomn/util/jre/1.1.8/bin/../lib/PA_RISC/native_threads/libjava.sl

From an Oracle metalink document I found that it is a known problem, "HP-UX do not allow dynamic loading of shared librarys which uses threaded local storage".

As I understand, this behaviour is made intentionally by HP. Is HP-UX different from other Unix here ?

Is there anyone who know more about this ?

5 REPLIES 5
Alessandro Pilati
Esteemed Contributor
Solution

Re: Threaded local storage ?

Leif,
I read something similar in a past posted forum:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=929331

I found this answer to this argument:
The problem is that any shared library that contains Thread Local Storage (TLS) cannot be used as a dependency of another shared library. There are at least two ways around this problem. First, you can link each incomplete executable against each of the dependent library that use TLS. Second, you can use the LD_PRELOAD environment variable to load the dependent shared libraries at startup. You can specify multiple shared libraries by separating each library name with a colon. You can specify the full path the the library, or leave the path off the library name to cause the loader to use the standard search path.


Check this link:
http://web.gat.com/comp/analysis/mdsplus/textfilebusy.html

Hope this could be a minimal help,

Rgds,
Alessandro
if you don't try, you'll never know if you are able to
Steven E. Protter
Exalted Contributor

Re: Threaded local storage ?

Is this the Oracle Application Server? If so, what version? Oracle has some workarounds for this issue at metalink.oracle.com

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Jean-Luc Oudart
Honored Contributor

Re: Threaded local storage ?

Leif

from HP doc Part Number: B2355-90730

http://docs.hp.com/en/B2355-90730/B2355-90730.html

Use caution when building shared libraries with external library dependencies. Any library that contains Thread Local Storage (TLS) should not be used as a dependency. If a dependent library contains TLS, and it is loaded during program startup (that is, not linked against the executable), the dynamic loader fails to perform the operation

You can use the LD_PRELOAD environment variable to load a shared library that contains thread-local storage to avoid the following error when loading the library dynamically:

/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local Storage: /usr/lib/libpthread.1

Regards
Jean-Luc
fiat lux
Ermin Borovac
Honored Contributor

Re: Threaded local storage ?

This is a quite common problem that pops up in one form or the other, but the basic problem is with libraries that contain thread local storage (TLS): libpthread and libcl.

Normally, shared libraries are linked directly with a program. Sometimes programmers decide that instead of linking a library directly to a program, they load a library when it's needed (with shl_load()) and unload it when it's no longer needed (shl_unload()).

In this case, library that is shl_loaded is libjava.sl. libjava.sl is linked with libpthread and/or libcl. libpthread and libcl are libraries that contain TLS.

Check with ldd

$ ldd /u10/test/testcomn/util/jre/1.1.8/bin/../lib/PA_RISC/native_threads/libjava.sl

The solution is to use environment variable LD_PRELOAD to load libraries in question (libjava.sl). The effect of using LD_PRELOADing the library is almost the same as linking it directly to the program.

$ LD_PRELOAD=/u10/test/testcomn/util/jre/1.1.8/bin/../lib/PA_RISC/native_threads/libjava.sl
Leif Halvarsson_2
Honored Contributor

Re: Threaded local storage ?

Hi,

Steven,
Yes, it is an Oracle application server but I am not sure about the version (I have not been in contact with the customer before). The only thing I know is that it is not the latest version and the customer is very negative to upgrading.

To All,

After some consulting we have decided that the problem is not ours, It should be solved by the Application developer. Many thanks for the hint about "LD_PRELOAD" , I will forward it.