Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8309305: sun/security/ssl/SSLSocketImpl/BlockedAsyncClose.java fails with jtreg test timeout #14378

Closed
wants to merge 2 commits into from

Conversation

mpdonova
Copy link
Contributor

@mpdonova mpdonova commented Jun 8, 2023

This PR improves the reliability of the BlockedAsyncClose test by addressing an edge case/race condition between the two test threads. The purpose of the test is to verify that an SSLSocket can be closed if a thread is blocked in a write operation.

The test starts a "write" thread that writes data to a socket until the output buffer was filled, causing the write operation to block. The main thread then calls SSLSocket.close(). The original code used Thread.sleep(1000) to wait for the write-thread to block. However, 1 second isn't always long enough and if the write-thread isn't blocked and the output buffer is full (or almost full), the socket.close() call may block when it tries to send the close_notify alert. This is the condition that caused this bug.

My change uses a Lock to determine if the write thread is blocked. In the write thread, the lock creates a critical section around the write() call. The main thread uses tryLock() with a timeout to determine that the write() call is taking too long and thus likely blocked.

While there, I also updated the test to use the SSLContextTemplate class.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8309305: sun/security/ssl/SSLSocketImpl/BlockedAsyncClose.java fails with jtreg test timeout (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14378/head:pull/14378
$ git checkout pull/14378

Update a local copy of the PR:
$ git checkout pull/14378
$ git pull https://git.openjdk.org/jdk.git pull/14378/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14378

View PR using the GUI difftool:
$ git pr show -t 14378

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14378.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 8, 2023

👋 Welcome back mdonovan! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 8, 2023
@openjdk
Copy link

openjdk bot commented Jun 8, 2023

@mpdonova The following label will be automatically applied to this pull request:

  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the security security-dev@openjdk.org label Jun 8, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 8, 2023

Webrevs

Co-authored-by: Andrey Turbanov <turbanoff@gmail.com>
@bridgekeeper
Copy link

bridgekeeper bot commented Jul 11, 2023

@mpdonova This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@mpdonova
Copy link
Contributor Author

Can someone please review this? Thanks!

Copy link
Member

@djelinski djelinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Some OSes spontaneously increase the buffer size after a few seconds, unblocking blocked write operations. We also use 10 seconds limit in networking tests, seems to work pretty well. See

// Time after which we deem that the local send buffer and remote
// receive buffer must be full.
// At the time of writing, using anything <= 5s on Mac will make the
// tests fail intermittently.
static final long MAX_WAIT_SEC = 10; // seconds.

@openjdk
Copy link

openjdk bot commented Jul 21, 2023

@mpdonova This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8309305: sun/security/ssl/SSLSocketImpl/BlockedAsyncClose.java fails with jtreg test timeout

Reviewed-by: djelinski

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 538 new commits pushed to the master branch:

  • 9e4fc56: 8293114: JVM should trim the native heap
  • 59f66a3: 8312293: SIGSEGV in jfr.internal.event.EventWriter.putUncheckedByte after JDK-8312086
  • 8cd43bf: 8312474: JFR: Improve logging to diagnose event stream timeout
  • 3e8f1eb: 8311976: Inconsistency in usage of CITimeVerbose to generate compilation logs
  • d4aacdb: 8306136: [vectorapi] Intrinsics of VectorMask.laneIsSet()
  • 783de32: 8300051: assert(JvmtiEnvBase::environments_might_exist()) failed: to enter event controller, JVM TI environments must exist
  • 4e8f331: 8312443: sun.security should use toLowerCase(Locale.ROOT)
  • d7b9416: 8199149: Improve the exception message thrown by VarHandle of unsupported operation
  • 354c660: 8307185: pkcs11 native libraries make JNI calls into java code while holding GC lock
  • bae2247: 8308591: JLine as the default Console provider
  • ... and 528 more: https://git.openjdk.org/jdk/compare/a6726b66dbb3ffa7b2245bb9c27c4bc87148f39c...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 21, 2023
@mpdonova
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 21, 2023

Going to push as commit 8042a50.
Since your change was applied there have been 540 commits pushed to the master branch:

  • 84b325b: 8312182: THPs cause huge RSS due to thread start timing issue
  • 842d632: 8227229: Deprecate the launcher -Xdebug/-debug flags that have not done anything since Java 6
  • 9e4fc56: 8293114: JVM should trim the native heap
  • 59f66a3: 8312293: SIGSEGV in jfr.internal.event.EventWriter.putUncheckedByte after JDK-8312086
  • 8cd43bf: 8312474: JFR: Improve logging to diagnose event stream timeout
  • 3e8f1eb: 8311976: Inconsistency in usage of CITimeVerbose to generate compilation logs
  • d4aacdb: 8306136: [vectorapi] Intrinsics of VectorMask.laneIsSet()
  • 783de32: 8300051: assert(JvmtiEnvBase::environments_might_exist()) failed: to enter event controller, JVM TI environments must exist
  • 4e8f331: 8312443: sun.security should use toLowerCase(Locale.ROOT)
  • d7b9416: 8199149: Improve the exception message thrown by VarHandle of unsupported operation
  • ... and 530 more: https://git.openjdk.org/jdk/compare/a6726b66dbb3ffa7b2245bb9c27c4bc87148f39c...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 21, 2023
@openjdk openjdk bot closed this Jul 21, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 21, 2023
@openjdk
Copy link

openjdk bot commented Jul 21, 2023

@mpdonova Pushed as commit 8042a50.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated security security-dev@openjdk.org
3 participants