United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 4621211 Java_java_io_UnixFileSystem_list calls MT-unsafe readdir()
4621211 : Java_java_io_UnixFileSystem_list calls MT-unsafe readdir()

Details
Type:
Bug
Submit Date:
2002-01-09
Status:
Closed
Updated Date:
2006-03-21
Project Name:
JDK
Resolved Date:
2006-03-21
Component:
core-libs
OS:
solaris_8
Sub-Component:
java.io
CPU:
sparc
Priority:
P4
Resolution:
Duplicate
Affected Versions:
1.4.0
Fixed Versions:
6

Related Reports
Duplicate:
Relates:

Sub Tasks

Description
Unsynchronized Java IO method calls MT-unsafe readdir(), that could
cause heap corruption.  readdir_r() should be used (or the method
should be made synchronized), though note there is an important
bug in the possible return values for readdir_r() - see BUGIDs
4616329, 4117832, 4152773.  Also, 4329196 for readdir64_r().

See comments (and attachments) for specific call location and more
detail.  Note that MT-unsafe getpwuid() is also called and should
also be fixed, but appears less likely to be invoked concurrently
in multiple threads.

BUGID 4308809 (and predecessor 4155856), had they been addressed,
would have greatly reduced the potential harm calling such MT-unsafe
routines could cause.

                                    

Comments
EVALUATION

This will be fixed as part of 6395581
                                     
2006-03-21
EVALUATION

Looking at the issue with readdir_r that is described in CR:4221365. This issue has been fixed in Solaris 10 fcs, S9 u3 and patches exist for S8. But because of the way File.list is specified (it does not throw an Exception), if readdir(_r) or any of its largefile support versions (readdir64_r) encounter an error we will simply return what files have been listed so far. So whether we are on a solaris platform that contains 4221365 or not it should not have any effect on what is returned from File.list. Hence it is safe to use readdir64_r in place of readdir.

Use largefile support version of reentrant readdir, readdir64_r because of CR 6395581.
                                     
2006-03-15
EVALUATION

This bug has been observed as part of the investigation of 6330699.
                                     
2005-09-30
SUGGESTED FIX

Either make the method synchronized (easiest, but not scalable)
or use readdir_r() - note caveats on bugs there.
                                     
2004-06-11
WORK AROUND

User (or JDK class) code calling this method can just make sure never to
call it in more than one thread (not acceptable), or (slightly better)
call it only from another synchronized method.
                                     
2004-06-11



Hardware and Software, Engineered to Work Together