Activity log for bug #312156

Date Who What changed Old value New value Message
2008-12-29 13:43:15 AlainKnaff bug added bug
2009-08-27 12:37:47 Jay Strict zsh (Ubuntu): status New Confirmed
2012-05-31 22:38:54 Daniel Hahler zsh (Ubuntu): importance Undecided Low
2012-05-31 22:38:54 Daniel Hahler zsh (Ubuntu): status Confirmed Triaged
2012-05-31 22:39:48 Daniel Hahler description When starting zsh in a subdirectory mounted using a bind mount, without the PWD variable being set, zsh becomes confused, and is unable to determine its working directory. Moreover, during the attempt to find out its working directory, it moves to a different place. In order to test 32-bit software on my 64-bit system, I've set up a chroot under /home/chroot/ubuntu-8.04-i386 under which I've mounted the real home using mount -o bind: mount -o bind /home /home/chroot/ubuntu-8.04-i386/home When I cd into any subdirectory of a subdirectory of /home/chroot/ubuntu-8.04-i386/home , unset PWD, and start zsh, zsh becomes confused as soon as its pwd algorithm crosses the bind mountpoint. Other shells, such as bash, handle this situation just fine. In the "wild" this situation happens when using schroot to execute a zsh in my 32 bit chroot environment (because by default, schroot unsets PWD before calling the shell). However, as shown above, the reason for the behavior is unrelated to the chroot system call, but can be reproduced with bind mounts alone. I suspect that the reason for this bug is some bogus "optimization" on how zsh detects mountpoints. Rather than assuming a mountpoint as soon as none of the inode numbers of the subdirectories of the parent match that of the current directory, zsh relies solely on a comparison of the device number of parent and current. However, in case of a bind mount both may match, even though a mountpoint is present. ----------------------------- > lsb_release -rd Description: Ubuntu 8.04.1 Release: 8.04 > apt-cache policy zsh zsh: Installé : 4.3.4-24ubuntu1 Candidat : 4.3.4-24ubuntu1 Table de version : *** 4.3.4-24ubuntu1 0 500 http://be.archive.ubuntu.com hardy/main Packages 100 /var/lib/dpkg/status How to reproduce: ---------------------------- mkdir -p /home/alain/tmp mkdir -p /home /home/chroot/ubuntu-8.04-i386/home mount -o bind /home /home/chroot/ubuntu-8.04-i386/home cd /home /home/chroot/ubuntu-8.04-i386/home/alain/tmp unset PWD zsh What I expect to happen: --------------------------------------- zsh's current dir should be /home/chroot/ubuntu-8.0.4-i386/home/alain/tmp , and pwd should show same What happened instead: ------------------------------------- zsh's current dir is /home/chroot/ubuntu-8.0.4-i386/home , and pwd shows "." When starting zsh in a subdirectory mounted using a bind mount, without the PWD variable being set, zsh becomes confused, and is unable to determine its working directory. Moreover, during the attempt to find out its working directory, it moves to a different place. In order to test 32-bit software on my 64-bit system, I've set up a chroot under /home/chroot/ubuntu-8.04-i386 under which I've mounted the real home using mount -o bind: mount -o bind /home /home/chroot/ubuntu-8.04-i386/home When I cd into any subdirectory of a subdirectory of /home/chroot/ubuntu-8.04-i386/home , unset PWD, and start zsh, zsh becomes confused as soon as its pwd algorithm crosses the bind mountpoint. Other shells, such as bash, handle this situation just fine. In the "wild" this situation happens when using schroot to execute a zsh in my 32 bit chroot environment (because by default, schroot unsets PWD before calling the shell). However, as shown above, the reason for the behavior is unrelated to the chroot system call, but can be reproduced with bind mounts alone. I suspect that the reason for this bug is some bogus "optimization" on how zsh detects mountpoints. Rather than assuming a mountpoint as soon as none of the inode numbers of the subdirectories of the parent match that of the current directory, zsh relies solely on a comparison of the device number of parent and current. However, in case of a bind mount both may match, even though a mountpoint is present. ----------------------------- > lsb_release -rd Description: Ubuntu 8.04.1 Release: 8.04 > apt-cache policy zsh zsh:   Installé : 4.3.4-24ubuntu1   Candidat : 4.3.4-24ubuntu1  Table de version :  *** 4.3.4-24ubuntu1 0         500 http://be.archive.ubuntu.com hardy/main Packages         100 /var/lib/dpkg/status How to reproduce: ---------------------------- mkdir -p /home/alain/tmp mkdir -p /home /home/chroot/ubuntu-8.04-i386/home mount -o bind /home /home/chroot/ubuntu-8.04-i386/home cd /home /home/chroot/ubuntu-8.04-i386/home/alain/tmp unset PWD zsh What I expect to happen: --------------------------------------- zsh's current dir should be /home/chroot/ubuntu-8.0.4-i386/home/alain/tmp , and pwd should show same What happened instead: ------------------------------------- zsh's current dir is /home/chroot/ubuntu-8.0.4-i386/home , and pwd shows "." TEST CASE: mkdir /tmp/foo mkdir /tmp/bar sudo mount -o bind /tmp/foo /tmp/bar cd /tmp/bar unset PWD zsh pwd => /tmp/foo But should be /tmp/bar
2012-05-31 22:40:38 Daniel Hahler summary zsh's pwd gets confused by bind mounts zsh's pwd gets confused with $PWD unset in mounted dir (bind/nfs)