JDK-7176176 : Need to make improvement to access temporary dir
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.crypto
  • Affected Version: 7
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-06-12
  • Updated: 2016-07-21
  • Resolved: 2014-06-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 JDK 9
7u111Fixed 8u101Fixed 9 b20Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
In javax.crypto.JarVerifier, File.list() is used to list all all names in the directory, it is not performance friendly. Need to make improvement.

Comments
Looks like a good fix to have in JDK 8u and perhaps 7u also. New report at JDK-8151434 - I'll open backports.
08-03-2016

This particular test was rewritten in JDK 8 because it was unstable. You might consider opening a bug to backport 8027624: changeset: 8650:6a6faa00acc4 user: dxu date: Fri Nov 01 14:40:03 2013 -0700 summary: 8027624: com/sun/crypto/provider/KeyFactory/TestProviderLeak.java unstable again This particular OOM exception is due to not enough GC space being freed up, and that's likely because of the -Xmx2m.
10-12-2013

Fails against JDK 7u51 and 7u55 nightly #section:main ----------messages:(3/471)---------- command: main -Xmx2m -XX:OldSize=1m -XX:NewSize=512k TestProviderLeak The original test invocation is below, but had to use the above workaround for bug 6923123. run main/othervm -Xmx2m TestProviderLeak reason: User specified action: run main/othervm -Xmx2m -XX:OldSize=1m -XX:NewSize=512k TestProviderLeak The original test invocation is below, but had to use the above workaround for bug 6923123. run main/othervm -Xmx2m TestProviderLeak elapsed time (seconds): 0.873 ----------System.out:(0/0)---------- ----------System.err:(29/1712)---------- java.lang.OutOfMemoryError: GC overhead limit exceeded at java.io.UnixFileSystem.list(Native Method) at java.io.File.list(File.java:1116) at javax.crypto.JarVerifier.getSystemEntropy(JarVerifier.java:788) at javax.crypto.JarVerifier.testSignatures(JarVerifier.java:706) at javax.crypto.JarVerifier.access$400(JarVerifier.java:34) at javax.crypto.JarVerifier$1.run(JarVerifier.java:183) at javax.crypto.JarVerifier$1.run(JarVerifier.java:149) at java.security.AccessController.doPrivileged(Native Method) at javax.crypto.JarVerifier.<clinit>(JarVerifier.java:148) at javax.crypto.JceSecurity.loadPolicies(JceSecurity.java:316) at javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:261) at javax.crypto.JceSecurity.access$000(JceSecurity.java:48) at javax.crypto.JceSecurity$1.run(JceSecurity.java:78) at java.security.AccessController.doPrivileged(Native Method) at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:76) at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:203) at TestProviderLeak.main(TestProviderLeak.java:58) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94) at java.lang.Thread.run(Thread.java:744) JavaTest Message: Test threw exception: java.lang.OutOfMemoryError: GC overhead limit exceeded JavaTest Message: shutting down test STATUS:Failed.`main' threw exception: java.lang.OutOfMemoryError: GC overhead limit exceeded ----------rerun:(22/1847)*---------- DISPLAY=sc11152338.us.oracle.com:1 \\ HOME=/Users/aurora \\ LANG=en_US.UTF-8 \\ LC_ALL=en_US.UTF-8 \\ PATH=/bin:/usr/bin \\ TZ=PST8PDT \\ CLASSPATH=/Users/aurora/sandbox/jtreg/lib/javatest.jar:/Users/aurora/sandbox/jtreg/lib/jtreg.jar:/Users/aurora/sandbox/gresults/testoutput/jdk_security2/JTwork/classes/com/sun/crypto/provider/KeyFactory:/Users/aurora/sandbox/testbase/test/com/sun/crypto/provider/KeyFactory:/Users/aurora/sandbox/jdk/lib/tools.jar \\ /Users/aurora/sandbox/jdk/bin/java \\ -Dtest.vm.opts='-d32 -d32 -ea -esa' \\ -Dcompile.jdk=/Users/aurora/sandbox/jdk \\ -Dtest.src.path=/Users/aurora/sandbox/testbase/test/com/sun/crypto/provider/KeyFactory \\ -Dtest.src=/Users/aurora/sandbox/testbase/test/com/sun/crypto/provider/KeyFactory \\ -Dtest.tool.vm.opts='-J-d32 -J-d32 -J-ea -J-esa' \\ -Dtest.class.path=/Users/aurora/sandbox/gresults/testoutput/jdk_security2/JTwork/classes/com/sun/crypto/provider/KeyFactory \\ -Dtest.timeout.factor=4.0 \\ -Dtest.classes=/Users/aurora/sandbox/gresults/testoutput/jdk_security2/JTwork/classes/com/sun/crypto/provider/KeyFactory \\ -Dtest.class.path.prefix=/Users/aurora/sandbox/gresults/testoutput/jdk_security2/JTwork/classes/com/sun/crypto/provider/KeyFactory:/Users/aurora/sandbox/testbase/test/com/sun/crypto/provider/KeyFactory \\ -Dtest.jdk=/Users/aurora/sandbox/jdk \\ -Dtest.java.opts= \\ -Dtest.compiler.opts= \\ -d32 -d32 -ea -esa -Xmx2m -XX:OldSize=1m -XX:NewSize=512k \\ com.sun.javatest.regtest.MainWrapper /Users/aurora/sandbox/gresults/testoutput/jdk_security2/JTwork/classes/com/sun/crypto/provider/KeyFactory/TestProviderLeak.jta The original test invocation is below, but had to use the above workaround for bug 6923123. run main/othervm -Xmx2m TestProviderLeak result: Failed. Execution failed: `main' threw exception: java.lang.OutOfMemoryError: GC overhead limit exceeded test result: Failed. Execution failed: `main' threw exception: java.lang.OutOfMemoryError: GC overhead limit exceeded
10-12-2013

Look into File.newDirectoryStream of NIO.2. Should also make a similar change in the SecureRandom code also, which the javax.crypto code is based from.
01-11-2013

EVALUATION We addressed this in the Sun provider SeedGenerator as part of: 7006126: (fs) Updates to file system API (1/2011) We should probably update the JarVerifier code similarly here: int count = 0; try (DirectoryStream<Path> stream = Files.newDirectoryStream(f.toPath())) { // We use a Random object to choose what file names // should be used. Otherwise on a machine with too // many files, the same first 1024 files always get // used. Any, We make sure the first 512 files are // always used. Random r = new Random(); for (Path entry: stream) { if (count < 512 || r.nextBoolean()) { md.update(entry.getFileName().toString().getBytes()); } if (count++ > 1024) { break; } }
13-06-2012