LD_LIBRARY_PATH side effects

I am having weird side effects when changing LD_LIBRARY_PATH .

When I add a path containing a library, for example.

 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_path/lib 

Then everything becomes incredibly slow. For example, a simple ls can last 10 seconds.

ldd output is exactly the same before and after changing LD_LIBRARY_PATH , and I tried to debug the execution of slow ls with strace : I get the same execution in both cases. Execution doesn't even get stuck at ls runtime (since strace doesn't output anything during a 10 second lag, and then unexpectedly executes ls fine). Therefore, I thought that this could come from my shell, but it’s the same, running strace on my bash and executing ls in both cases gives me the same strace result: the shell executes ls and waits to complete its execution (the last strace exits before delay strace is waitpid(...) ). Therefore, I assume that something is wrong between running ls and executing it, as if it were a kernel level issue. This really works if sleep was done on ls (using 0 cpu).

During the lag, my processor and network activity are absolutely normal ...

Note that the library in the new LD path does not conflict with any "standard library", so in my example this does not interfere with ls .

Therefore, I am interested in explaining in more detail the side effects of LD_LIBRARY_PATH or how to deeply debug my example.

+7
source share
2 answers

This post is closed, so I don’t know if you are already finding a solution. Anyway, I don't know if this will help, but on most modern GNU / Linux systems, using LD_LIBRARY_PATH is deprecated and not recommended.

Therefore, I have a few suggestions:

  • if you want to continue using it, first try the pending one first, and do not add the library path to LD_LIBRARY_PATH. This should help if it takes a long time to scan paths in previous library directories.

  • Use the LDCONFIG system, which is the (new) correct way to use LD directories at present. You just need to add the path to your library in the /etc/ld.so.conf file or, better, add the file to /etc/ld.so.conf.d/, which contains the path to your library (this will be if there is an include directive in /etc/ld.so.conf, which usually takes place by default). Then run sudo ldconfig to update the LD system search path.

I hope this help. Greetings

+1
source

I'm not sure what else is in your LD_LIBRARY_PATH or library that you are trying to add or which program you are using, but you are probably better off writing a shell script to change LD_LIBRARY_PATH only for a program that needs an additional library so that your system functions, such as ls , not hurt.

 #!/bin/bash export LD_LIBRARY_PATH=/my_path/lib program_name 

Create file and chmod +x wrapper_name

0
source

All Articles