Review Request JDK-7119643: It is not possible to read files with a path longer than 2048 characters

David Holmes david.holmes at
Mon Mar 24 12:17:37 UTC 2014


On 24/03/2014 10:13 PM, Dmitry Samersoff wrote:
> Poonam,
> As far as I understand, MAX_PATH is here for a while but later we start
> I would recommend to replace all usage of MAX_PATH and PATH_MAX

The issue here is to remove the internal limitation. We can't just make 
the replacement you suggest because we will suddenly be allocating 4KB 
stack buffers where they were previously 2KB. That is bound to break 


> if you fill that these changes is go out of scope of JDK-7119643, please
> replace it inside os:stat() only to solve immediate needs and file a
> separate CR to have it cleaned up.
> -Dmitry
> On 2014-03-24 06:55, Poonam Bajaj wrote:
>> Hi Dmitry,
>> On 3/24/2014 12:49 AM, Dmitry Samersoff wrote:
>>> Poonam,
>>> 1.
>>> MAXPATHLEN == PATH_MAX and it's a system constant that comes from
>>> sys/param.h and linux/limits.h so current behavior of hotspot is
>>> absolutely correct.
>>> Moreover, we uses MAXPATHLEN in many places in os_*.cpp files, so this
>>> patch makes hotspot behavior inconsistent.
>>> Typical value of PATH_MAX is 4096 so it's unclean for me why we have
>>> problems with 2048 bytes file.
>>> We probably should check our reference build platform.
>> The purpose of this change is to revert back to the same behavior as it
>> was before the  fix for 6348631 where we didn't have any path limitation
>> in os::open() and os::stat() functions.
>> But yes, you are right. We have the following in sys/param.h and
>> linux/limits.h for the maximum allowed path length on linux platforms:
>> #define PATH_MAX        4096    /* # chars in a path name including nul */
>> #define MAXPATHLEN      PATH_MAX
>> and MAXPATHLEN is also used in os_linux.cpp. So, if we have to insert
>> the path limitation in os::open() and os::stat(), we should be using
>> MAXPATHLEN at all the places in os_linux.cpp. Why was MAX_PATH defined
>> and to a different value than MAXPATHLEN which is inconsistent with the
>> linux definition?
>>> 2.
>>> Test could be a pure java.
>> Ok, will do.
>> Thanks,
>> Poonam
>>> -Dmitry
>>> On 2014-03-21 16:52, Poonam Bajaj wrote:
>>>> Hi,
>>>> Review request for:
>>>> JDK-7119643<>: It is
>>>> not possible to read files with a path longer than 2048 characters
>>>> Problem and Fix: This bug is a regression from 6u29 and exists only on
>>>> Linux platform. With the fix for 6348631, a limit of MAX_PATH (2K) got
>>>> introduced on the file path length in the os::open() and os::stat()
>>>> functions in os_linux.cpp. These changes remove that limit. These
>>>> changes also add a regression test case to check that the files having
>>>> path longer than 2048 are read without any error.
>>>> Webrev:
>>>> This fix needs to go into 9, 8u, 7u and 6u.
>>>> Thanks,
>>>> Poonam

More information about the hotspot-runtime-dev mailing list