By chance, is this occurring on a directory using OverlayFS (or some other special file system type)?
I just had this issue where my cross-compiled version of bash would use an internal implementation of getcwd
which has issues with OverlayFS. I found information about this here:
It seems that this can be traced to an internal implementation of getcwd() in bash. When cross-compiled, it can't check for getcwd() use of malloc, so it is cautious and sets GETCWD_BROKEN and uses an internal implementation of getcwd(). This internal implementation doesn't seem to work well with OverlayFS.
http://permalink.gmane.org/gmane.linux.embedded.yocto.general/25204
You can configure and rebuild bash with bash_cv_getcwd_malloc=yes
(if you're actually building bash and your C library does malloc a getcwd call).