RFR: 8258753: StartTlsResponse.close() hangs due to synchronization issues

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: 8258753: StartTlsResponse.close() hangs due to synchronization issues

Prajwal Kumaraswamy-2
**Scenario:**
1. Issue occurs in a muti-threaded environment where SSL socket read() and close() are invoked in parallel.
2. SSL socket read is already called.
2. close() calls waitForCloseNotify() -> decode() ->....-> socketRead0() to read the close_notify acknowledgment.
3. Since there is no synchronization between these read operations, the thread which had already invoked read(), reads the close_notify acknowledgment.
4. The thread (which calls waitForCloseNotify() -> read() ) waits indefinitely in socketRead0() and hangs.
5. Reproduced and tested the fix against a real time MS AD LDAP server.

**Additional details:**
1. The issue occurs in JDK 8u261 and above.
2. JDK 8u251 works fine because it has synchronization along with the state of connection maintained.
3. Mach5 run is green.
https://mach5.us.oracle.com/mdash/jobs/pkumaraswamy-jdk-jdk-2-20210317-1430-19174037

-------------

Commit messages:
 - 8258753: StartTlsResponse.close() hangs due to synchronization issues

Changes: https://git.openjdk.java.net/jdk/pull/3068/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3068&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8258753
  Stats: 17 lines in 1 file changed: 8 ins; 2 del; 7 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3068.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3068/head:pull/3068

PR: https://git.openjdk.java.net/jdk/pull/3068
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8258753: StartTlsResponse.close() hangs due to synchronization issues

Xue-Lei Andrew Fan
On Thu, 18 Mar 2021 07:07:56 GMT, Prajwal Kumaraswamy <[hidden email]> wrote:

> **Scenario:**
> 1. Issue occurs in a muti-threaded environment where SSL socket read() and close() are invoked in parallel.
> 2. SSL socket read is already called.
> 2. close() calls waitForCloseNotify() -> decode() ->....-> socketRead0() to read the close_notify acknowledgment.
> 3. Since there is no synchronization between these read operations, the thread which had already invoked read(), reads the close_notify acknowledgment.
> 4. The thread (which calls waitForCloseNotify() -> read() ) waits indefinitely in socketRead0() and hangs.
> 5. Reproduced and tested the fix against a real time MS AD LDAP server.

Marked as reviewed by xuelei (Reviewer).

-------------

PR: https://git.openjdk.java.net/jdk/pull/3068
Reply | Threaded
Open this post in threaded view
|

Integrated: 8258753: StartTlsResponse.close() hangs due to synchronization issues

Prajwal Kumaraswamy-2
In reply to this post by Prajwal Kumaraswamy-2
On Thu, 18 Mar 2021 07:07:56 GMT, Prajwal Kumaraswamy <[hidden email]> wrote:

> **Scenario:**
> 1. Issue occurs in a muti-threaded environment where SSL socket read() and close() are invoked in parallel.
> 2. SSL socket read is already called.
> 2. close() calls waitForCloseNotify() -> decode() ->....-> socketRead0() to read the close_notify acknowledgment.
> 3. Since there is no synchronization between these read operations, the thread which had already invoked read(), reads the close_notify acknowledgment.
> 4. The thread (which calls waitForCloseNotify() -> read() ) waits indefinitely in socketRead0() and hangs.
> 5. Reproduced and tested the fix against a real time MS AD LDAP server.

This pull request has now been integrated.

Changeset: 41555332
Author:    Prajwal Kumaraswamy <[hidden email]>
Committer: Xue-Lei Andrew Fan <[hidden email]>
URL:       https://git.openjdk.java.net/jdk/commit/41555332
Stats:     17 lines in 1 file changed: 8 ins; 2 del; 7 mod

8258753: StartTlsResponse.close() hangs due to synchronization issues

Reviewed-by: xuelei

-------------

PR: https://git.openjdk.java.net/jdk/pull/3068