This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 4a332ab Fix APR crash on shutdown. 4a332ab is described below commit 4a332ab493a18c62e5932860eef09e9cda61ccd4 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 | 11 +++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index f369000..96542db 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -672,11 +672,22 @@ public class AprEndpoint extends AbstractEndpoint<Long> implements SNICallBack { 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 d3c11e5..b873535 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -105,6 +105,17 @@ issues do not "pop up" wrt. others). --> <section name="Tomcat 8.5.73 (schultz)"> + <subsection name="Coyote"> + <changelog> + <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> +</section> +<section name="Tomcat 8.5.73 (schultz)"> <subsection name="Catalina"> <changelog> <fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org