This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients csernazs, pitrou, skrah
Date 2010-07-13.12:41:53
SpamBayes Score 2.339684e-12
Marked as misclassified No
Message-id <20100713124047.GA12009@yoda.bytereef.org>
In-reply-to <1279022763.71.0.470174223778.issue9185@psf.upfronthosting.co.za>
Content
Thanks for having a look at the patch!

Antoine Pitrou <report@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.
History
Date User Action Args
2010-07-13 12:41:56skrahsetrecipients: + skrah, csernazs, pitrou
2010-07-13 12:41:54skrahlinkissue9185 messages
2010-07-13 12:41:53skrahcreate