This is an automated email from the ASF dual-hosted git repository.

remm 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 bb4a5a0860 Avoid possible crashes with OpenSSL
bb4a5a0860 is described below

commit bb4a5a08603d8e1d67b4249fe8c634571a6ec852
Author: remm <r...@apache.org>
AuthorDate: Thu Sep 26 16:53:03 2024 +0200

    Avoid possible crashes with OpenSSL
    
    Some SSL_CTX might be lying around and still tied to GC. GC might occur
    after Library.terminate.
    This should mostly occur with the Tomcat testsuite.
---
 java/org/apache/catalina/core/AprLifecycleListener.java            | 2 ++
 java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java | 2 ++
 webapps/docs/changelog.xml                                         | 7 ++++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/core/AprLifecycleListener.java 
b/java/org/apache/catalina/core/AprLifecycleListener.java
index d3fbfbdfb1..4a60d53ff8 100644
--- a/java/org/apache/catalina/core/AprLifecycleListener.java
+++ b/java/org/apache/catalina/core/AprLifecycleListener.java
@@ -193,6 +193,8 @@ public class AprLifecycleListener implements 
LifecycleListener {
         AprStatus.setAprAvailable(false);
         fipsModeActive = false;
         sslInitialized = false; // Well we cleaned the pool in terminate.
+        // There could be unreferenced SSL_CTX still waiting for GC
+        System.gc();
         Library.threadSafeTerminate();
     }
 
diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java 
b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
index df90d84bcf..17204fd274 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
@@ -350,6 +350,8 @@ public class OpenSSLLibrary {
 
             try {
                 if (OpenSSL_version_num() < 0x3000000fL) {
+                    // There could be unreferenced SSL_CTX still waiting for GC
+                    System.gc();
                     freeDHParameters();
                     if (!MemorySegment.NULL.equals(enginePointer)) {
                         ENGINE_free(enginePointer);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 68af6d696a..61001544a9 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -151,8 +151,13 @@
       <add>
         Add <code>server</code> and <code>serverRemoveAppProvidedValues</code>
         to the list of attributes the HTTP/2 protocol will inherit from the
-        HTTP/1.1 connector it is nested within. 
+        HTTP/1.1 connector it is nested within. (markt)
       </add>
+      <fix>
+        Avoid possible crashes when using Apache Tomcat Native, caused by
+        destroying SSLContext objects through GC after APR has been terminated.
+        (remm)
+      </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

Reply via email to