ls --color hangs for directories linked from network

Bug #264313 reported by Uxinn
48
This bug affects 10 people
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

Binary package hint: coreutils

ls --color hangs for directories linked from network resources if those resources are not available
I guess it hangs in trying to validate the link ( have not tried to wait and see if it times out or not )

easily reproducible.

annoying since --color is default

Running Ubuntu 8.0.4
2.6.24-21-generic #1 SMP Mon Aug 25 16:57:51 UTC 2008 x86_64 GNU/Linux
ls (GNU coreutils) 6.10

ISSUE:

since ls --color will try to determine if a symlink is broken or not (so that it will be correctly coloured), it *will* timeout on vanished resources.

WORKAROUND:

Inhibit 'ls' from following symlinks (at least in the context of --color):
eval `dircolors -b | sed s/or=[^:]*://`

Add the above to your profile.

Revision history for this message
Kamil Dudka (kdudka) wrote :

There is a simple workaround - this avoids ls from following symlinks (at least in the context of --color):
eval `dircolors -b | sed s/or=[^:]*://`

Try add something like this to your profile.

Revision history for this message
Ryan Kavanagh (ryanakca) wrote :

I can confirm this on Karmic,
Linux lambda 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux
ls (GNU coreutils) 7.4

This occurs here if I mount the nfs share foo:/c/d onto /a/B, poweroff foo and then run 'ls --color' in /a. This does not happen after I run 'sudo umount -fl /a/B'.

Changed in coreutils (Ubuntu):
status: New → Confirmed
Revision history for this message
Philip Muškovac (yofel) wrote :

Still reproducable on lucid.
~/ext is a symlink to /media/ext here which is a NFS mount.

strace ls --color=auto shows:
lstat64("ext", {st_mode=S_IFLNK|0777, st_size=10, ...}) = 0
readlink("ext", "/media/ext", 11) = 10
stat64("/media/ext",

the same while /media/ext is available gives:
lstat64("ext", {st_mode=S_IFLNK|0777, st_size=10, ...}) = 0
readlink("ext", "/media/ext", 11) = 10
stat64("/media/ext", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0

The lstat64 call is done for all files/dirs with --color=auto, while readlink() and stat64() only get called for symlinks.

Revision history for this message
Kamil Dudka (kdudka) wrote :

Do not expect this to be fixed in coreutils. There is no generally better solution I am aware of. You have in fact two choices - either give up broken checking of broken symlink at all, or wait some time for the symlinks to be checked. Consider using timeout(1) utility to not wait indefinitely in that case.

Revision history for this message
C de-Avillez (hggdh2) wrote :

I am tending to close this one WONTFIX...

Changed in coreutils (Ubuntu):
importance: Undecided → Low
description: updated
Revision history for this message
Parag Joshi (pmj005) wrote :

I don't think this bug should be closed or label WONTFIX.

Nothing should hang.

I recently face similar issue and ls keeps hanging and even the workaround with eval doesn't fix it.

Revision history for this message
Parag Joshi (pmj005) wrote :

I reported Bug #906643 which involves sshfs and this eval work-around didn't work for me. Not sure if the cause (following symlinks for coloring) is similar in my case.

Revision history for this message
Thorsten Frank (thorstenfrank1978) wrote :

I can confirm this on Ubuntu 14.04, but as has been pointed out, I don't really expect a "fix" to this. However, the workaround at first didn't work for me until I'd figured out that you ALSO have to make sure that you don't have an alias set for ls which uses the "-F" option.

"-F" tries the same as the "or=..."-Option in dircolors - it categorizes the files in a directory listing, and therefore tries to determine whether or not a symlink is broken.

To determine whether the workaround works for you, try this:

eval `dircolors -b | sed s/or=[^:]*://`
\ls -l --colors=auto

The backslash in front of the ls-command circumvents any set aliases, so you get the real behaviour of exactly the following command.

Revision history for this message
Max Schillinger (maxschillinger) wrote :

Same issue in Ubuntu 18.04.

Revision history for this message
Max Schillinger (maxschillinger) wrote :

The workaround mentioned works for me. For fish users: Put

eval (dircolors -c | sed 's/or=[^:]*://')

in your `~/.config/fish/config.fish`.

And you have to modify the builtin `ls` function:

cp /usr/share/fish/functions/ls.fish ~/.config/fish/functions/

Then open `~/.config/fish/functions/ls.fish` and comment out this line:

set -a param --indicator-style=classify

Revision history for this message
Amos (a-storkey) wrote :

I do think the fact that a workaround exists is not enough. I really think the default behaviour in Ubuntu of a oft-used command should not create hangs of well over a minute in fairly standard circumstances. It also hangs on links that are not accessible because they have not been Kerberos authenticated or are on unmounted USB devices.

So I do think the default should at least be changed here. It is unreasonable default behaviour, not least because it is really unobvious to most users why it happens.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.