This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 07f6c6a Fix APR crash on shutdown. 07f6c6a is described below commit 07f6c6a85fbd5254d5df5a504081ee198445d4d7 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Nov 11 12:58:52 2021 +0000 Fix APR crash on shutdown. These crashes have been observed with the new BuildBot CI system. Local testing and a 10.0.x CI run indicate this fix addresses the issue --- java/org/apache/tomcat/util/net/AprEndpoint.java | 19 +++++++++++++++---- webapps/docs/changelog.xml | 5 +++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index 7599670..5a8442d 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -710,11 +710,22 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB log.warn(sm.getString("endpoint.err.attach", Integer.valueOf(rv))); return false; } - if (SSLSocket.handshake(socket) != 0) { - if (log.isDebugEnabled()) { - log.debug(sm.getString("endpoint.err.handshake") + ": " + SSL.getLastError()); + + // Need to make sure the socket doesn't get closed while the + // handshake is in progress as that could trigger a JVM crash. + // Like stopInternal(), use the blocking status write lock as a + // proxy for a lock on writing to the socket. + WriteLock wl = ((AprSocketWrapper) socketWrapper).getBlockingStatusWriteLock(); + wl.lock(); + try { + if (SSLSocket.handshake(socket) != 0) { + if (log.isDebugEnabled()) { + log.debug(sm.getString("endpoint.err.handshake") + ": " + SSL.getLastError()); + } + return false; } - return false; + } finally { + wl.unlock(); } if (negotiableProtocols.size() > 0) { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index ddee7bb..460e413 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -170,6 +170,11 @@ open a server socket as continuing in this case will trigger a JVM crash. (markt) </fix> + <fix> + Fix a potential JVM crash when using the APR/Native connector with TLS. + A crash could occur if the connector was stopped whilst a connection was + performing a TLS handshake. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org