Blame SOURCES/pr3479-rh1486025.patch

045ef6
# HG changeset patch
045ef6
# User andrew
045ef6
# Date 1508194072 -3600
045ef6
#      Mon Oct 16 23:47:52 2017 +0100
045ef6
# Node ID 5dcb55da00c1531264934559c9f10c2e0ae46420
045ef6
# Parent  bf62c56e3604fee0018b19f65fd56c76dc156630
045ef6
PR3479, RH1486025: ECC and NSS JVM crash
045ef6
Summary: SunEC provider can have multiple instances, leading to premature NSS shutdown
045ef6
Contributed-by: Martin Balao <mbalao@redhat.com>
045ef6
045ef6
diff --git a/make/mapfiles/libsunec/mapfile-vers b/make/mapfiles/libsunec/mapfile-vers
045ef6
--- openjdk/jdk/make/mapfiles/libsunec/mapfile-vers
045ef6
+++ openjdk/jdk/make/mapfiles/libsunec/mapfile-vers
045ef6
@@ -32,7 +32,6 @@
045ef6
                 Java_sun_security_ec_ECDSASignature_verifySignedDigest;
045ef6
                 Java_sun_security_ec_ECDHKeyAgreement_deriveKey;
045ef6
 		Java_sun_security_ec_SunEC_initialize;
045ef6
-		Java_sun_security_ec_SunEC_cleanup;
045ef6
         local:
045ef6
                 *;
045ef6
 };
045ef6
diff --git a/src/share/classes/sun/security/ec/SunEC.java b/src/share/classes/sun/security/ec/SunEC.java
045ef6
--- openjdk/jdk/src/share/classes/sun/security/ec/SunEC.java
045ef6
+++ openjdk/jdk/src/share/classes/sun/security/ec/SunEC.java
045ef6
@@ -83,21 +83,8 @@
045ef6
     }
045ef6
 
045ef6
     /**
045ef6
-     * Cleanup native resources during finalisation.
045ef6
-     */
045ef6
-    @Override
045ef6
-    protected void finalize() {
045ef6
-        cleanup();
045ef6
-    }
045ef6
-
045ef6
-    /**
045ef6
      * Initialize the native code.
045ef6
      */
045ef6
     private static native void initialize();
045ef6
 
045ef6
-    /**
045ef6
-     * Cleanup in the native layer.
045ef6
-     */
045ef6
-    private static native void cleanup();
045ef6
-
045ef6
 }
045ef6
diff --git a/src/share/native/sun/security/ec/ECC_JNI.cpp b/src/share/native/sun/security/ec/ECC_JNI.cpp
045ef6
--- openjdk/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp
045ef6
+++ openjdk/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp
045ef6
@@ -525,14 +525,12 @@
045ef6
 }
045ef6
 
045ef6
 JNIEXPORT void
045ef6
-JNICALL Java_sun_security_ec_SunEC_cleanup
045ef6
-  (JNIEnv *env, jclass UNUSED(clazz))
045ef6
+JNICALL JNI_OnUnload
045ef6
+  (JavaVM *vm, void *reserved)
045ef6
 {
045ef6
 #ifdef SYSTEM_NSS
045ef6
     RNG_RNGShutdown();
045ef6
-    if (SECOID_Shutdown() != SECSuccess) {
045ef6
-	ThrowException(env, INTERNAL_ERROR);
045ef6
-    }
045ef6
+    SECOID_Shutdown();
045ef6
 #endif
045ef6
 }
045ef6