JDK-7118373 : (se) Potential leak file descriptor when deregistrating at around the same time as an async close
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 5.0u31
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_redhat_5.0
  • CPU: x86
  • Submitted: 2011-12-06
  • Updated: 2020-01-31
  • Resolved: 2012-06-18
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.
Other JDK 6 JDK 7 JDK 8
5.0u35Fixed 6u32Fixed 7u6Fixed 8 b36Fixed
Related Reports
Relates :  
A CU found domain socket leak occurs in JDK5u28/6u30/7.

JDK : jdk7GA, jdk6u30, jdk5u31

% java -version
java version "1.5.0_31"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_31-b02)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_31-b02, mixed mode)

%java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

 % java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

OS : 
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
Linux XXXXXX 2.6.18-164.11.1.el5 #1 SMP Wed Jan 6 13:26:04 EST 2010 x86_64 x86_64 x86_64 GNU/Linux

1. Compile the attached e.java and execute "java e"
2. Invoke "lsof -U -a -p [PID]"
 If you can see several UNIX domain Sockets are created, that shows the problem is reproduced.

% lsof -U -a -p 3855
java    3855 tbaba    4u  unix 0xffff810010ccf940      61967223 socket
java    3855 tbaba   17u  unix 0xffff810010cce600      61967239 socket

It depends on enviromnment. In some machine, it will take 5 - 10 minutes  to reproduce this, in some machines, it needs several hours to reproduce.

EVALUATION This bug can be reproduced by using jdk5u31 to run e.java on linux-x68 machine jsn-gtwy-1.us for 15 mins. Verify it is fixed in jdk8-b37 by running same test on same machine.

EVALUATION This has been diagnosed as a race between the deregistration and close. The preClose is missing a check for the ST_KILLED state.

EVALUATION Each Selector instance on Linux has socketpair that is used by the wakeup mechanism. There is also a socketpair used for the asynchronous close mechanism. So it is normal for lsof to report a java process using Unix domain sockets, in the test case then seeing 2 sockets is normal. We ran the test for >1h on RHEL5 and did not observe any more than 2 sockets.