JDK-4621211 : Java_java_io_UnixFileSystem_list calls MT-unsafe readdir()
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2002-01-09
  • Updated: 2006-03-21
  • Resolved: 2006-03-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6Resolved
Related Reports
Duplicate :  
Relates :  
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
21-03-2006

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.
15-03-2006

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

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.
11-06-2004

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