New submission from Zsolt Cserna <zsolt.cse...@morganstanley.com>:

os.getcwd() causes infinite loop on solaris10 when the length of the current 
directory is greater than 1024 (them limit of the maximum absolute path).

os.getcwd is implemented by a while loop in python, see the function 
posix_getcwd in posixmodule.c. That while loop loops forever because on solaris 
it sets errno to ERANGE and res to NULL - even if there will be no positive 
results from getcwd due to the extra long path.
This infinite while cycle also causes eating up the memory.

I think the solution would be implementing a hard limit for this while loop. It 
could be either fixed (16k for example), or dymanic: comparing the MAXPATHLEN 
macro to the size of the allocated buffer and if the size of the buffer is 
greater than MAXLPATHLEN then raise an OSError exception with the current errno.

That bug was triggered by test_posix unittest.

----------
components: Library (Lib)
messages: 109459
nosy: csernazs
priority: normal
severity: normal
status: open
title: os.getcwd causes infinite loop on solaris
type: behavior
versions: Python 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

Reply via email to