You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/11/11 16:45:04 UTC

[tomcat] branch 8.5.x updated: Fix APR crash on shutdown.

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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch 8.5.x updated: Fix APR crash on shutdown.

Posted by Mark Thomas <ma...@apache.org>.
On 12/11/2021 14:06, Christopher Schultz wrote:
> Mark,
> 
> On 11/11/21 11:45, markt@apache.org wrote:
>> 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
> 
> Do you think this requires a cancellation of the VOTE and a re-roll of 
> the 8.5.x release?

You could argue it either way. On the "no" side, it isn't a regression - 
it has been like this for a while and I haven't seen any reports of 
actual crashes fro users. On the "yes" side it is a JVM crash.

We are still seeing some strangeness in the CI runs that I haven't got 
to the bottom of yet.

I'm currently thinking continue as we are and we always have the option 
of pulling the December release forward a little if we need to. That 
view might change once we have clearer idea of what is going on with the 
CI runs.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch 8.5.x updated: Fix APR crash on shutdown.

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mark,

On 11/11/21 11:45, markt@apache.org wrote:
> 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

Do you think this requires a cancellation of the VOTE and a re-roll of 
the 8.5.x release?

-chris

> ---
>   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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org