Stefan Krah <stefan-use...@bytereef.org> added the comment: Thanks for having a look at the patch!
Antoine Pitrou <rep...@bugs.python.org> wrote: > I'm not sure I understand the cause of the problem. Does getcwd() fail on > Solaris when the path length is higher than PATH_MAX, even if you pass a big > enough buffer? If the path length exceeds PATH_MAX, getcwd() keeps returning NULL and setting ERANGE, so it enters an infinite loop, exhausting all memory. This is a bug in Solaris getcwd(). > First, your patch makes getcwd() return an error when the path length is > longer than PATH_MAX, which it doesn't today. This is a regression and > shouldn't probably go in. Hm, on Linux I can't use os.getcwd() with paths longer than PATH_MAX as things are now: $ cd /tmp/ $ for i in `seq 1 410`; do mkdir "123456789"; cd "123456789"; done cd: error retrieving current directory: getcwd: cannot access parent directories: File name too long $ python2.6 Python 2.6.5+ (release26-maint:81682M, Jun 6 2010, 11:22:46) [GCC 4.1.3 20080623 (prerelease) (Ubuntu 4.1.2-23ubuntu3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.getcwd() Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 36] File name too long > Second, the test_posix change is a bit too tolerant. IMO it should check that > the error is ERANGE, and that we are under Solaris. Otherwise the error > shouldn't happen, should it? If you change 1027 to 4098, the test currently fails on Linux, too. I think the only reason why it never failed is that most systems have PATH_MAX=4096. OSError: [Errno 36] File name too long > Also, I wonder why py3k uses a simple hard-coded buffer of 1026 bytes (not > even PATH_MAX+2). This is even worse than what you are proposing. I'll open a > separate issue for it. Good question. posix_getcwdu() also uses a buffer of 1026 in 2.7. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9185> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com