Linux – `ls` causes Segmentation Fault on a specific directory

linuxlsredhatsegmentation-fault

I used $HOME/.local as prefix to install some applications without root access. There is one directory inside $HOME/.local that I can't execute ls command:

[tuananh@server lib]$ ls
Segmentation fault
[tuananh@server lib]$ cd ..
[tuananh@server .local]$ ls lib
audit                    libform.a         
libncurses.a             libopenblas.so.0
...
[tuananh@server .local]$ 

What could posibly be the reason for that? uname -a for my server:

Linux server 2.6.32-358.2.1.el6.x86_64 #1 SMP Tue Mar 12 14:18:09 CDT 2013 x86_64 x86_64 x86_64 GNU/Linux

EDIT: Output of LD_TRACE_LOADED_OBJECTS=1 ls. I found some libraries loaded from this directory. So now what should I do to find the one that cause the problem?

linux-vdso.so.1 =>  (0x00007fff831b8000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003d94800000)
librt.so.1 (0x00007fdcde5a3000)
libcap.so.2 => /lib64/libcap.so.2 (0x0000003d95c00000)
libacl.so.1 => /lib64/libacl.so.1 (0x0000003d97c00000)
libc.so.6 (0x00007fdcde1f5000)
libdl.so.2 (0x00007fdcddff1000)
/lib64/ld-linux-x86-64.so.2 (0x0000003d92c00000)
libpthread.so.0 (0x00007fdcdddd3000)
libattr.so.1 => /lib64/libattr.so.1 (0x0000003d96800000)

Best Answer

Most likely you have some library installed in there that gets loaded instead of the system ones when you execute a command in there and it is binary incompatible with the commands in your system. It's probably something related to glibc or so.

You can confirm this by running LD_TRACE_LOADED_OBJECTS=1 ls and examining the output to see if it includes any of the files in the current directory.

Related Topic