JDK-8240233 : SSLSocketImpl/SSLSocketBruceForceClose.java failed due to "SSLException: readHandshakeRecord"
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.net.ssl
  • Affected Version: 11,15
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2020-02-28
  • Updated: 2024-06-03
  • Resolved: 2024-06-03
Related Reports
Duplicate :  
Relates :  
Description
The following test failed in the JDK15 CI:

sun/security/ssl/SSLSocketImpl/SSLSocketBruceForceClose.java

Here's a snippet from the log file:

#section:main
----------messages:(4/179)----------
command: main SSLSocketBruceForceClose
reason: User specified action: run main/othervm SSLSocketBruceForceClose 
Mode: othervm [/othervm specified]
elapsed time (seconds): 61.277
----------configuration:(0/0)----------
----------System.out:(0/0)----------
----------System.err:(65/4336)----------
===================================
loop 0
===================================
Starting client
Accepting client requests
Connecting to server at port 49324
Reading data from client
Sending data to server ...
client socket closed
javax.net.ssl.SSLException: readHandshakeRecord
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1379)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:437)
	at java.base/sun.security.ssl.SSLSocketImpl.ensureNegotiated(SSLSocketImpl.java:878)
	at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:969)
	at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:297)
	at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
	at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:188)
	at java.base/java.io.InputStreamReader.read(InputStreamReader.java:181)
	at java.base/java.io.BufferedReader.fill(BufferedReader.java:161)
	at java.base/java.io.BufferedReader.readLine(BufferedReader.java:326)
	at java.base/java.io.BufferedReader.readLine(BufferedReader.java:392)
	at SSLSocketBruceForceClose.test(SSLSocketBruceForceClose.java:76)
	at SSLSocketBruceForceClose.main(SSLSocketBruceForceClose.java:48)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:832)
	Suppressed: java.net.SocketException: Broken pipe
		at java.base/sun.nio.ch.NioSocketImpl.implWrite(NioSocketImpl.java:420)
		at java.base/sun.nio.ch.NioSocketImpl.write(NioSocketImpl.java:440)
		at java.base/sun.nio.ch.NioSocketImpl$2.write(NioSocketImpl.java:826)
		at java.base/java.net.Socket$SocketOutputStream.write(Socket.java:1052)
		at java.base/sun.security.ssl.SSLSocketOutputRecord.encodeAlert(SSLSocketOutputRecord.java:82)
		at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:355)
		at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:267)
		at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:440)
		... 17 more
Caused by: java.net.SocketException: Broken pipe
	at java.base/sun.nio.ch.NioSocketImpl.implWrite(NioSocketImpl.java:420)
	at java.base/sun.nio.ch.NioSocketImpl.write(NioSocketImpl.java:440)
	at java.base/sun.nio.ch.NioSocketImpl$2.write(NioSocketImpl.java:826)
	at java.base/java.net.Socket$SocketOutputStream.write(Socket.java:1052)
	at java.base/sun.security.ssl.SSLSocketOutputRecord.encodeChangeCipherSpec(SSLSocketOutputRecord.java:233)
	at java.base/sun.security.ssl.OutputRecord.changeWriteCiphers(OutputRecord.java:182)
	at java.base/sun.security.ssl.ServerHello$T13ServerHelloProducer.produce(ServerHello.java:690)
	at java.base/sun.security.ssl.SSLHandshake.produce(SSLHandshake.java:440)
	at java.base/sun.security.ssl.ClientHello$T13ClientHelloConsumer.goServerHello(ClientHello.java:1252)
	at java.base/sun.security.ssl.ClientHello$T13ClientHelloConsumer.consume(ClientHello.java:1188)
	at java.base/sun.security.ssl.ClientHello$ClientHelloConsumer.onClientHello(ClientHello.java:851)
	at java.base/sun.security.ssl.ClientHello$ClientHelloConsumer.consume(ClientHello.java:812)
	at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)
	at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:444)
	at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:422)
	at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:181)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:167)
	at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1462)
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1370)
	... 18 more

JavaTest Message: Test threw exception: javax.net.ssl.SSLException: readHandshakeRecord
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: javax.net.ssl.SSLException: readHandshakeRecord
----------rerun:(34/5682)*----------
Comments
This test has not failed since last year, and it was ran thousands of times since then. Cannot reproduce anymore.
03-06-2024

We notice the same issue too every few weeks in our jdk8 and 11 tests.
15-09-2021

Hi [~xuelei], I can see the test SSLSocketBruceForceClose was added along with the following bug fix: https://bugs.openjdk.java.net/browse/JDK-8209333 This test is failing very very occasionally in CI, and the cause seems to be 'Broken pipe' which is caused by the other end closing the connection while reading/writing. I was not able to reproduce it (ran it thousands of times with multithreading). A workaround would be adding synchronisation in the test to make sure the connections are not closed until the other end has finished consuming the data, but I am afraid that scenario is the very goal of the test and syncing client and server would not be the best approach. I could also handle the exception, what do you think makes more sense to get rid of this failure?
18-02-2021

It looks like the same issue as JDK-8240233, may caused by the underlying socket update.
11-03-2020