Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8249017

Native memory leak is caused by the method: java.security.KeyStore

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 11.0.5-oracle
    • Fix Version/s: None
    • Component/s: security-libs
    • Labels:

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Java 11.0.5 and Solaris 11 Sparc

      A DESCRIPTION OF THE PROBLEM :
      Native memory leak is caused by the method: java.security.KeyStore.getEntry( String, KeyStore.ProtectionParameter )
      The memory used is not on the Java heap, so it is not reclaimed by garbage collection.

      REGRESSION : Last worked in version 8

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      java.security.KeyStore.getEntry( String, KeyStore.ProtectionParameter )
      The memory used is not on the Java heap, so it is not reclaimed by garbage collection.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The same program does not leak on Windows or Linux.
      ACTUAL -
      The memory used is not on the Java heap, so it is not reclaimed by garbage collection.

      ---------- BEGIN SOURCE ----------
      import java.io.File;
      import java.io.FileInputStream;
      import java.io.InputStream;
      import java.security.KeyStore;
      import java.security.KeyStoreException;

      public class Leaky
      {
      public void test() throws Exception
      {
      KeyStore ks = createKeyStore();
      String alias = "mydomain";
      char[] passwd = {'m','y','d','o','m','a','i','n',';'};
              KeyStore.ProtectionParameter kpp = new KeyStore.PasswordProtection(passwd);
              for (int at=0; at<50; at++)
              {
               //System.out.println( "getEntry " + at );
               // THIS IS THE LEAK
               KeyStore.SecretKeyEntry ke = (KeyStore.SecretKeyEntry)ks.getEntry( alias, kpp );
              }
      }

          private KeyStore createKeyStore() throws KeyStoreException
          {
           KeyStore ks = KeyStore.getInstance("JCEKS");
                  
           try (InputStream in = new FileInputStream(new File("domains.reg")))
           {
           ks.load( in, null );
           }
           catch (Throwable t)
           {
           t.printStackTrace();
           System.exit(-1);
           }
                              
           return ks;
          }

      public static void main(String[] args) throws Exception
      {
      Leaky leak = new Leaky();
      leak.test();
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              tongwan Andrew Wang
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: