I am having strange side effects on changing LD_LIBRARY_PATH
.
When I append a path containing a library, e.g. :
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_path/lib
Then, everything becomes unbelievably slow. For example, a simple ls
can be 10 seconds long.
ldd
output is exactly the same before and after the LD_LIBRARY_PATH
change and I tried to debug the execution of the slow ls
with strace
: I get the exact same execution in both cases. The execution does not even get stuck during the execution of ls
(since strace
does not output anything during the 10-second lag and then suddenly perfectly executes ls
). So I thought it could come from my shell, but this is the same, running strace
on my bash and executing ls
in both cases gives me the same strace
output : the shell executes ls
and wait for the end of its execution (the last strace
output before the lag strace
is waitpid(...)
). So I guess something wrong happens between the the launch of ls
and its execution, like if it was a kernel-level issue. It really acts like if a sleep
was made on ls
(0 cpu usage).
During the lag, my CPU and network activity are perfectly normal...
Note that the library in the new LD path does not conflict with any "standard library", so it does not disturb ls
in my example.
So I am interesting in deeper explanations about LD_LIBRARY_PATH
side effects or how to deeply debug my example.
The LD_LIBRARY_PATH environment variable tells Linux applications, such as the JVM, where to find shared libraries when they are located in a different directory from the directory that is specified in the header section of the program.
For security reasons, LD_LIBRARY_PATH is ignored at runtime for executables that have their setuid or setgid bit set. This severely limits the usefulness of LD_LIBRARY_PATH.
LD_LIBRARY_PATH - stands for LOAD LIBRARY PATH or some times called as LOADER LIBRARY PATH.
This post is quit old, so I don't know if you find already a solution. Anyway, I don't know if this may help, but in most modern GNU/Linux systems, the use of LD_LIBRARY_PATH is deprecated and discouraged.
Therefore I have a couple of suggestions:
if you want to continue using it, try first by pre-pending instead of appending your library path to the LD_LIBRARY_PATH. This should help if there is something that takes long time to scan the path in previous library directories.
Use LDCONFIG system, which is the (new) proper way of using LD directories nowadays. You simply have to add the path to your library in /etc/ld.so.conf file, or better, add a file in /etc/ld.so.conf.d/ which contains the path to your library (it will be sourced if there is an include directive in /etc/ld.so.conf, which is usually the case by default). Then run sudo ldconfig
to update the system LD search path.
I hope this help. Cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With