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