JDK-8151571 : InnocuousThread cannot be created during early startup
  • Type: Bug
  • Component: core-libs
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-03-10
  • Updated: 2017-07-10
  • Resolved: 2016-03-25
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 9
9 b112Fixed
Related Reports
Relates :  
Relates :  
Description
After the fix for JDK-8149925 was pushed, the System/LoggerFinder tests

java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinderTest.java
java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java
java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java
java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java
java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java
java/lang/System/LoggerFinder/internal/backend/LoggerFinderBackendTest.java

started failing across platforms. Sampling from the jtr file

Error occurred during initialization of VM
java.lang.ExceptionInInitializerError
...
Caused by: java.lang.IllegalStateException: recursive invocation
...
Comments
It is verified by running tests in java/lang/System/LoggerFinder with JDK 9 build 176.
10-07-2017

Or... Here's an even simpler reproducer: touch xxx java -Djava.system.class.loader=AnyLoader -cp xxx AnyClass If the classpath includes a path that is an existent normal file (even if it is empty - 0 bytes), a JarLoader is employed and before it even finds out that it is not a jar file, NativeBuffer is initialized. So is it possible, that some left-over file or a file from some concurrent jtreg execution coincides with a classpath of othervm when the test is executed?
10-03-2016

does jtreg put any jar(s) on the classpath of othervm normally? If the custom class loader class is in an exploaded directory then it works. The code path must use a JarLoader to trigger this. There must be some jtreg configuration somewhere that prepends a jar file to the classpath of othervm (such as instrumentation agent or something like that)...
10-03-2016

The weird thing is why it's not reproducible by running jtreg on those tests on local system.
10-03-2016

Simple reproducer: Take any.jar file (one with just META-INF/MANIFEST.MF will do). Invoke: java -Djava.system.class.loader=AnyLoader -cp any.jar AnyClass
10-03-2016

I can't reliably reproduce this issue. The first time I ran BaseLoggerFinderTest.java on the linux system that reports this test failure (Linux 2.6.39-300.20.1.el6uek.x86_64) I reproduced the recursion initialization issue. However later rerunning it it passes. We need to understand under what circumstances this code path occurs and why we can't reproduce it on some systems before we can decide on the resolution. In jake, we rework the system initialization code that ClassLoader::getSystemClassLoader should be available even the VM is not booted. This might become a non-issue when jake is integrated into jdk9.
10-03-2016

Innocuous thread sets TCCL to system class loader which is available after the system is booted. The tests set -Djava.system.class.loader to override the system class loader. When creating the custom system class loader, it hits this recursive invocation. One possible option is to have the innocuous thread to set TCCL only if it's booted; otherwise, it's created early during startup by the system. Caused by: java.lang.IllegalStateException: recursive invocation at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1444) at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1430) at jdk.internal.misc.InnocuousThread.<init>(InnocuousThread.java:61) at jdk.internal.misc.InnocuousThread.<init>(InnocuousThread.java:50) at jdk.internal.ref.CleanerImpl$InnocuousThreadFactory$1.run(CleanerImpl.java:330) at jdk.internal.ref.CleanerImpl$InnocuousThreadFactory$1.run(CleanerImpl.java:327) at java.security.AccessController.doPrivileged(Native Method) at jdk.internal.ref.CleanerImpl$InnocuousThreadFactory.newThread(CleanerImpl.java:327) at jdk.internal.ref.CleanerImpl.start(CleanerImpl.java:116) at java.lang.ref.Cleaner.create(Cleaner.java:175) at jdk.internal.ref.CleanerFactory.<clinit>(CleanerFactory.java:37) at sun.nio.fs.NativeBuffer.<init>(NativeBuffer.java:61) at sun.nio.fs.NativeBuffers.allocNativeBuffer(NativeBuffers.java:49) at sun.nio.fs.UnixNativeDispatcher.copyToNativeBuffer(UnixNativeDispatcher.java:44) at sun.nio.fs.UnixNativeDispatcher.stat(UnixNativeDispatcher.java:289) at sun.nio.fs.UnixFileAttributes.get(UnixFileAttributes.java:70) at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:52) at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:145) at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99) at java.nio.file.Files.readAttributes(Files.java:1739) at java.util.zip.ZipFile$Source.get(ZipFile.java:924) at java.util.zip.ZipFile.<init>(ZipFile.java:213) at java.util.zip.ZipFile.<init>(ZipFile.java:145) at java.util.jar.JarFile.<init>(JarFile.java:352) at sun.misc.URLClassPath$JarLoader.getJarFile(URLClassPath.java:731) at sun.misc.URLClassPath$JarLoader.access$600(URLClassPath.java:620) at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:676) at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:669) at java.security.AccessController.doPrivileged(Native Method) at sun.misc.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:668) at sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:643) at sun.misc.URLClassPath$3.run(URLClassPath.java:394) at sun.misc.URLClassPath$3.run(URLClassPath.java:380) at java.security.AccessController.doPrivileged(Native Method) at sun.misc.URLClassPath.getLoader(URLClassPath.java:379) at sun.misc.URLClassPath.getLoader(URLClassPath.java:356) at sun.misc.URLClassPath.getResource(URLClassPath.java:222) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:365) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:262) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:372) at java.lang.SystemClassLoaderAction.run(ClassLoader.java:2203) at java.lang.SystemClassLoaderAction.run(ClassLoader.java:2189) at java.security.AccessController.doPrivileged(Native Method) at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1450) at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1430)
10-03-2016