Skip to content

Conversation

@mpdonova
Copy link
Contributor

@mpdonova mpdonova commented Dec 6, 2024

I was unable to reproduce the error but I suspect the error is caused by the server-side closing the socket as soon as the write operation is done. I added a read() call on the server to ensure the client initiates connection close


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-8339356: Test javax/net/ssl/SSLSocket/Tls13PacketSize.java failed with java.net.SocketException: An established connection was aborted by the software in your host machine (Bug - P4)

Reviewers

Contributors

  • Daniel Jeliński <djelinski@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22591

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

Using diff file

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

Using Webrev

Link to Webrev Comment

…h java.net.SocketException: An established connection was aborted by the software in your host machine
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 6, 2024

👋 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
Copy link

openjdk bot commented Dec 6, 2024

@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:

8339356: Test javax/net/ssl/SSLSocket/Tls13PacketSize.java failed with java.net.SocketException: An established connection was aborted by the software in your host machine

Co-authored-by: Daniel Jeliński <djelinski@openjdk.org>
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 261 new commits pushed to the master branch:

  • 23d6f74: 8346463: Add test coverage for deploying the default provider as a module
  • 484229e: 8346306: Unattached thread can cause crash during VM exit if it calls wait_if_vm_exited
  • b0c40aa: 8340401: DcmdMBeanPermissionsTest.java and SystemDumpMapTest.java fail with assert(_stack_base != nullptr) failed: Sanity check
  • 6b89954: 8346475: RISC-V: Small improvement for MacroAssembler::ctzc_bit
  • 00d8407: 8346016: Problemlist vm/mlvm/indy/func/jvmti/mergeCP_indy2manyDiff_a in virtual thread mode
  • 5db0a13: 8346132: fallbacklinker.c failed compilation due to unused variable
  • 5590669: 8346570: SM cleanup of tests for Beans and Serialization
  • c8e94ab: 8346532: XXXVector::rearrangeTemplate misses null check
  • f7f2b42: 8346300: Add @test annotation to TCKZoneId.test_constant_OLD_IDS_POST_2024b test
  • a0b7c4f: 8346324: javax/swing/JScrollBar/4865918/bug4865918.java fails in CI
  • ... and 251 more: https://git.openjdk.org/jdk/compare/a49f0776eb176129f558b6fab3f50e0453f8cbcb...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 rfr Pull request is ready for review label Dec 6, 2024
@openjdk
Copy link

openjdk bot commented Dec 6, 2024

@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 Dec 6, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 6, 2024

Webrevs


sslOS.write(appData);
sslOS.flush();
sslIS.read();
Copy link
Member

Choose a reason for hiding this comment

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

The failure is caused by closing the socket before all the data sent by the client is read. In order to read all the data, you need something like:

Suggested change
sslIS.read();
sslIS.read(appData, 1, appData.length-1);

The failure is hard to reproduce. You might need to repeat the test a few hundred times to see if it's gone. And it only affects Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ran the test many hundreds of times and didn't see the error. I updated the code as you suggested and ran it 100s of times again without reproducing it.

Copy link
Member

@djelinski djelinski Dec 13, 2024

Choose a reason for hiding this comment

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

FWIW, here's a diff that reliably reproduces the issue:

diff --git a/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java b/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java
index a7809754ed0..b57f1665408 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java
@@ -358,6 +358,13 @@ void deliver(byte[] source, int offset, int length) throws IOException {
                 }

                 offset += fragLen;
+                if (offset < limit && tc.sslConfig.isClientMode) {
+                    try {
+                        Thread.sleep(100);
+                    } catch (InterruptedException e) {
+                        //throw new RuntimeException(e);
+                    }
+                }
             }
         } finally {
             recordLock.unlock();

pretty typical for reproducing race conditions, it adds a delay on the right path.

Just verified, the PR doesn't fix the failure. Probably because the call to read returns whatever data is available immediately, and doesn't wait for more data to become available.

EDIT: corrected the diff


sslOS.write(appData);
sslOS.flush();
sslIS.read(appData, 1, appData.length-1);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sslIS.read(appData, 1, appData.length-1);
int drained = 1;
while (drained < appData.length) {
drained += sslIS.read(appData, drained, appData.length - drained);
}

this one actually works, I checked.

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.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 19, 2024
@mpdonova
Copy link
Contributor Author

/contributor add @djelinski

@openjdk
Copy link

openjdk bot commented Dec 19, 2024

@mpdonova
Contributor Daniel Jeliński <djelinski@openjdk.org> successfully added.

@mpdonova
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Dec 19, 2024

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

  • 23d6f74: 8346463: Add test coverage for deploying the default provider as a module
  • 484229e: 8346306: Unattached thread can cause crash during VM exit if it calls wait_if_vm_exited
  • b0c40aa: 8340401: DcmdMBeanPermissionsTest.java and SystemDumpMapTest.java fail with assert(_stack_base != nullptr) failed: Sanity check
  • 6b89954: 8346475: RISC-V: Small improvement for MacroAssembler::ctzc_bit
  • 00d8407: 8346016: Problemlist vm/mlvm/indy/func/jvmti/mergeCP_indy2manyDiff_a in virtual thread mode
  • 5db0a13: 8346132: fallbacklinker.c failed compilation due to unused variable
  • 5590669: 8346570: SM cleanup of tests for Beans and Serialization
  • c8e94ab: 8346532: XXXVector::rearrangeTemplate misses null check
  • f7f2b42: 8346300: Add @test annotation to TCKZoneId.test_constant_OLD_IDS_POST_2024b test
  • a0b7c4f: 8346324: javax/swing/JScrollBar/4865918/bug4865918.java fails in CI
  • ... and 251 more: https://git.openjdk.org/jdk/compare/a49f0776eb176129f558b6fab3f50e0453f8cbcb...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 19, 2024

@mpdonova Pushed as commit f6e7713.

💡 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

Development

Successfully merging this pull request may close these issues.

2 participants