JDK-6296324 : Deadlock in RMIConnector.close
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-07-13
  • Updated: 2010-07-29
  • Resolved: 2005-09-30
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
5.0u7Fixed 6 b55Fixed
Related Reports
Relates :  
Description
The locking protocol used in javax.management.remote.rmi.RMIConnector is susceptible to deadlock.  The particular deadlock observed is this:

"ClientNotifForwarder-6":
        at javax.management.remote.rmi.RMIConnector.close(RMIConnector.java:407)
        - waiting to lock <0xf102ceb8> (a javax.management.remote.rmi.RMIConnector)
        at javax.management.remote.rmi.RMIConnector$RMIClientCommunicatorAdmin.gotIOException(RMIConnector.java:1442)
        - locked <0xf0f22ac0> (a [I)
        at javax.management.remote.rmi.RMIConnector$RMINotifClient.fetchNotifs(RMIConnector.java:1294)
        at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.fetchNotifs(ClientNotifForwarder.java:508)
        at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.run(ClientNotifForwarder.java:399)
        at com.sun.jmx.remote.internal.ClientNotifForwarder$LinearExecutor$1.run(ClientNotifForwarder.java:83)
"main":
        at javax.management.remote.rmi.RMIConnector.close(RMIConnector.java:412)
        - waiting to lock <0xf0f22ac0> (a [I)
        - locked <0xf102ceb8> (a javax.management.remote.rmi.RMIConnector)
        at Client2.closeConnectors2(Client2.java:45)
        at Client2.main(Client2.java:171)

RMIConnector.close() is synchronized and contains a block "synchronized(terminationLock)".  When it is called by user code it therefore takes the locks in the order RMIConnector.this->terminationLock.  On the other hand, RMIConnector.RMIClientCommunicatorAdmin.gotIOException calls RMIConnector.close() from with a "synchronized(terminationLock)" block.  So it takes the locks in the order terminationLock->RMIConnector.this[->terminationLock].  This can lead to deadlock as has been observed by the customer.
###@###.### 2005-07-13 14:39:20 GMT

Comments
EVALUATION When an IOException is detected by a RMI client, and the client decides to close the connection, it is not necessary to call the method "close" under the synchronization of the veariable "terminationLock", because the method "close" is under synchronization protection.
15-09-2005

WORK AROUND There is no need to close the connection when you get a connection-failed notification. It will be closed immediately after delivery of the notification. ###@###.### 2005-07-13 14:56:24 GMT
13-07-2005

EVALUATION Lock protocol must be revised. ###@###.### 2005-07-13 14:44:43 GMT
13-07-2005