RFR: 8129957 - Deadlock in JNDI LDAP implementation when closing the LDAP context

Rob McKenna rob.mckenna at oracle.com
Mon Aug 10 13:06:37 UTC 2015


Hi folks,

We have a hang between LdapClient / Ctx due to the fact that 
Connection.cleanup() calls LdapClient.processConnectionClosure which 
locks the unsolicited vector and in turn calls LdapCtx.fireUnsolicited 
which locks the eventSupport object. Unfortunately when an 
LdapCtx.close() occurs at the same time, its removeUnsolicited method 
locks the eventSupport object first and then attempts to call 
LdapClient.removeUnsolicited which attempts to lock the unsolicited vector.

So:

thread 1:

Connection.cleanup ->
LdapClient.processConnectionClosure (LOCK VECTOR) ->
LdapCtx.fireUnsolicited (LOCK EVENTSUPPORT)

(LdapClient is looping through LdapCtx objects in the unsolicited vector)

thread 2:

LdapCtx.close (LOCK LDAPCTX) ->
LdapCtx.removeUnsolicited (LOCK EVENTSUPPORT) ->
LdapClient.removeUnsolicited (LOCK VECTOR)

(A single LdapCtx removes itself from its LdapClient unsolicited list)


My proposed solution is to have both threads lock the LdapClient before 
locking either the unsolicited vector or the eventSupport object.

Webrev at: http://cr.openjdk.java.net/~robm/8129957/webrev.01/

	-Rob



More information about the core-libs-dev mailing list