Manifestation of 2290 with non-IBM JVM?

Hello Gradle forum,

I am unable to run unit tests on my gradle install. It’s very, very bizarre as I work on a team of 10+ people who can all use Grade fine. I even went so far as to get a new PC, reinstall everything from scratch and try again… to no avail. Colleagues have logged in as themselves on my machine and it fails for them as well. After some googling the nearest thing I can find is bug GRADLE-2290 http://issues.gradle.org/browse/GRADLE-2290 but I am not using the IBM JVM, I am using jdk1.6.31 downloaded from Oracle.

I thought perhaps the SecurityManager could not write to disk, so I edited the gradle script to include -Djava.io.tmpdir=C:/tmp and then making this folder… but I still get the error.

The stack trace is pasted below. I’m on Windows 7.

Any pointers would be welcome! Cheers, John

:unitTests Error occurred during initialization of VM java.lang.InternalError: Could not create SecurityManager: org.gradle.process.internal.child.BootstrapSecurityManager

at sun.misc.Launcher.(Launcher.java:90)

at sun.misc.Launcher.(Launcher.java:43)

at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1337)

at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1319)

Could not write process standard input. java.io.IOException: The pipe has been ended

at java.io.FileOutputStream.writeBytes(Native Method)

at java.io.FileOutputStream.write(FileOutputStream.java:282)

at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)

at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)

at org.gradle.process.internal.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:51)

at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)

at java.lang.Thread.run(Thread.java:662) Error occurred during initialization of VM java.lang.InternalError: Could not create SecurityManager: org.gradle.process.internal.child.BootstrapSecurityManager

at sun.misc.Launcher.(Launcher.java:90)

at sun.misc.Launcher.(Launcher.java:43)

at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1337)

at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1319)

Could not write process standard input. java.io.IOException: The pipe has been ended

at java.io.FileOutputStream.writeBytes(Native Method)

at java.io.FileOutputStream.write(FileOutputStream.java:282)

at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)

at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)

at org.gradle.process.internal.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:51)

at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)

at java.lang.Thread.run(Thread.java:662) Gradle Worker 2 finished with (non-zero) exit value 1. org.gradle.process.internal.ExecException: Gradle Worker 2 finished with (non-zero) exit value 1.

at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:339)

at org.gradle.process.internal.DefaultWorkerProcess.onProcessStop(DefaultWorkerProcess.java:78)

at org.gradle.process.internal.DefaultWorkerProcess.access$000(DefaultWorkerProcess.java:31)

at org.gradle.process.internal.DefaultWorkerProcess$1.executionFinished(DefaultWorkerProcess.java:51)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)

at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)

at org.gradle.messaging.dispatch.BroadcastDispatch.dispatch(BroadcastDispatch.java:88)

at org.gradle.messaging.dispatch.BroadcastDispatch.dispatch(BroadcastDispatch.java:32)

at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)

at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)

at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)

at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)

at java.lang.Thread.run(Thread.java:662) Error occurred during initialization of VM java.lang.InternalError: Could not create SecurityManager: org.gradle.process.internal.child.BootstrapSecurityManager

at sun.misc.Launcher.(Launcher.java:90)

at sun.misc.Launcher.(Launcher.java:43)

at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1337)

at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1319)

Could not write process standard input. java.io.IOException: The pipe has been ended

at java.io.FileOutputStream.writeBytes(Native Method)

at java.io.FileOutputStream.write(FileOutputStream.java:282)

at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)

at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)

at org.gradle.process.internal.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:51)

at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)

at java.lang.Thread.run(Thread.java:662) Gradle Worker 3 finished with (non-zero) exit value 1. etc etc

This isn’t GRADLE-2290. The relevant bits are:

:unitTests
 Error occurred during initialization of VM
 java.lang.InternalError: Could not create SecurityManager: org.gradle.process.internal.child.BootstrapSecurityManager
 at sun.misc.Launcher.(Launcher.java:90)
 at sun.misc.Launcher.(Launcher.java:43)
 at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1337)
 at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1319)

(What follows afterwards looks more like consecutive errors.)

Unfortunately, the ‘InternalError’ swallows the true cause of the problem. You could try to debug the problem as follows:

  • Execute ‘gradle test -Dtest.debug=true’. * Once the build suspends, connect a debugger on port 5005 that has exception breakpoints set for ‘java.lang.IllegalAccessException’, ‘java.lang.InstantiationException’, ‘java.lang.ClassNotFoundException’, ‘java.lang.ClassCastException’. * If an exception is caught, inspect it.

I can’t tell for sure that this will work, but it’s worth a try.

Hi Peter, Thanks a lot for your reply. I am currently trying to work out how to get IntelliJ to attach to the remote gradle process. I figure I need to make a new project, containing the Gradle source code, then start Gradle as you described and then connect with the remote debugger.

What I have noticed is that the first time I run the command you gave me it works ok and pauses on 5005 waiting for a debugger. If it doesn’t find one it fails, spewing hundreds of errors like the below. It will then persistently fail if retried, unless I restart my PC.

The errors it spews are a little similar to the original stack trace.Could this be related do you think? The IOException error and “pipe has been ended” message are the same.

Cheers, John

FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
Could not write process standard input.
java.io.IOException: The pipe has been ended
        at java.io.FileOutputStream.writeBytes(Native Method)
        at java.io.FileOutputStream.write(FileOutputStream.java:282)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
        at org.gradle.process.internal.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:51)
        at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Gradle Worker 29 finished with (non-zero) exit value 1.
org.gradle.process.internal.ExecException: Gradle Worker 29 finished with (non-zero) exit value 1.
        at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:339)
        at org.gradle.process.internal.DefaultWorkerProcess.onProcessStop(DefaultWorkerProcess.java:78)
        at org.gradle.process.internal.DefaultWorkerProcess.access$000(DefaultWorkerProcess.java:31)
        at org.gradle.process.internal.DefaultWorkerProcess$1.executionFinished(DefaultWorkerProcess.java:51)
        at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.messaging.dispatch.BroadcastDispatch.dispatch(BroadcastDispatch.java:88)
        at org.gradle.messaging.dispatch.BroadcastDispatch.dispatch(BroadcastDispatch.java:32)
        at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
        at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
        at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
        at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
Could not write process standard input.
java.io.IOException: The pipe has been ended
        at java.io.FileOutputStream.writeBytes(Native Method)
        at java.io.FileOutputStream.write(FileOutputStream.java:282)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
        at org.gradle.process.internal.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:51)
        at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Gradle Worker 30 finished with (non-zero) exit value 1.
org.gradle.process.internal.ExecException: Gradle Worker 30 finished with (non-zero) exit value 1.
        at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:339)
        at org.gradle.process.internal.DefaultWorkerProcess.onProcessStop(DefaultWorkerProcess.java:78)
        at org.gradle.process.internal.DefaultWorkerProcess.access$000(DefaultWorkerProcess.java:31)
        at org.gradle.process.internal.DefaultWorkerProcess$1.executionFinished(DefaultWorkerProcess.java:51)
        at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.messaging.dispatch.BroadcastDispatch.dispatch(BroadcastDispatch.java:88)
        at org.gradle.messaging.dispatch.BroadcastDispatch.dispatch(BroadcastDispatch.java:32)
        at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
        at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
        at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
        at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)

The ‘InternalError’ occurs when starting up a test JVM, before any Gradle code gets invoked. Hence you don’t need Gradle sources and can use any Java project (even an “empty” one). Just create a “Remote” run configuration and set port to 5005. Don’t forget to set the exception breakpoints beforehand.

It will then persistently fail if retried, unless I restart my PC.

My best guess is that Windows doesn’t free the port for a while. I also recommend to run without the Gradle daemon (‘–no-daemon’), although I’m not sure how it would interfere here.

The errors it spews are a little similar to the original stack trace.Could this be related do you think?

The consecutive errors are similar because the error happens at the same point (namely when starting up a test JVM) and is equally fatal. Other than that, I don’t think there’s a connection.

Cheers Peter. Actually all other Java apps work fine on my machine, thus me originally thinking it was a gradle issue. Still messing round with debuggers… john

Just to be clear, what I was saying is that you can use any IDEA Java project to debug this Gradle issue. All you need to do is to connect a debugger on port 5005.

Hi Peter,

Some more information… I have used Eclipse as a debugger and as you said pre-set the Exceptions in it. I start gradle with the command you specified: gradle test -Dtest.debug=true And immediately it shows a ClassNotFoundException. Like in this screenshot:

It would lead me to believe that the classloader for the child gradle processes cannot find the org.gradle.process.internal.child.BootStrapSecurityManager class, which is in the gradle-core-1.3.jar jar file. This isn’t anything wrong with gradle, as my colleagues installations all work fine, it’s something to do with my personal setup and environment or classpath or something. Any idea why the child process would not be able to load this class? cheers, John

Just to clarify, the stacktrace below is clearer. It seems the failure is a ClassNotFoundException on the sun.misc.Launcher as it cannot find the class for the gradle BootstrapSecurityManager . Why would the classpath of the child process be lacking this? cheers john

Could not write standard input into: Gradle Worker 36.
java.io.IOException: The pipe has been ended
        at java.io.FileOutputStream.writeBytes(Native Method)
        at java.io.FileOutputStream.write(FileOutputStream.java:282)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
        at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:53)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Process 'Gradle Worker 36' finished with non-zero exit value 1
org.gradle.process.internal.ExecException: Process 'Gradle Worker 36' finished with non-zero exit value 1
        at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:363)
        at org.gradle.process.internal.DefaultWorkerProcess.onProcessStop(DefaultWorkerProcess.java:82)
        at org.gradle.process.internal.DefaultWorkerProcess.access$000(DefaultWorkerProcess.java:33)
        at org.gradle.process.internal.DefaultWorkerProcess$1.executionFinished(DefaultWorkerProcess.java:54)
        at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:88)
        at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:32)
        at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at $Proxy42.executionFinished(Unknown Source)
        at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:212)
        at org.gradle.process.internal.DefaultExecHandle.finished(DefaultExecHandle.java:310)
        at org.gradle.process.internal.ExecHandleRunner.completed(ExecHandleRunner.java:107)
        at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:87)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Error occurred during initialization of VM
java.lang.InternalError: Could not create SecurityManager: jarjar.org.gradle.process.internal.child.BootstrapSecurityManager
        at sun.misc.Launcher.<init>(Launcher.java:90)
        at sun.misc.Launcher.<clinit>(Launcher.java:43)
        at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1337)
        at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1319)

I’m not seeing a ‘ClassNotFoundException’ in that trace. Is there more that you didn’t paste?

When I connected the debugger it immediately shows the ClassNotFoundException (see the image I attached in an earlier post). In the source code of sun.misc.Launcher you can see how this becomes the InternalError:

if (s != null) {

91

SecurityManager sm = null;

92

if ("".equals(s) || “default”.equals(s)) {

93

sm = new java.lang.SecurityManager();

94

} else {

95

try {

96

sm = (SecurityManager)loader.loadClass(s).newInstance();

97

} catch (IllegalAccessException e) {

98

} catch (InstantiationException e) {

99

} catch (ClassNotFoundException e) {

100

} catch (ClassCastException e) {

101

}

102

}

103

if (sm != null) {

104

System.setSecurityManager(sm);

105

} else {

106

throw new InternalError(

107

"Could not create SecurityManager: " + s);

108

}

109

}

Pretty crappy actually… they swallow the exception.

Are you able to see exactly what the arguments were to ‘java’ to start the process? I suspect that the ‘-cp’ property is getting mangled somehow.

Hi Luke,

No, this is the problem, I can’t see the command gradle is using to start the child processes. Is there a way to get it to display?

I wonder what is messing with the cp. Should I be setting anything more in my environmental variables than JAVA_HOME and adding the jdk and gradle dist bin directory onto the path?

cheers, John

I recall something similar (but not the same) being reported recently, which turned out to be a JDK bug on Windows. I looked for the report but couldn’t find it.

In order to rule this out, would it be possible to try with jdk 1.6.41?

ok will do.

Luke, Tried with 1.6.41 and have same problem.

I cocked-up the previous debugging and my explanation was slightly wrong. I debugged again and the exception actually occurs in java.net.URLClassLoader line 194 as it cannot find the resource:

String path = name.replace(’.’, ‘/’).concat(".class");

Resource res = ucp.getResource(path, false);

if (res != null) {

try {

return defineClass(name, res, true);

} catch (IOException e) {

throw new ClassNotFoundException(name, e);

}

} else {

throw new ClassNotFoundException(name);

}

In my debugger I can see the ‘name’ variable is:

jarjar.org.gradle.process.internal.launcher.GradleWorkerMain

Is it correct that it should have “jarjar” on the front of it? If you could highlight to me which class pumps out the new java command for the child process then perhaps I can stick a breakpoint there and see what the classpath is?

Cheers, John

That’s shame, was worth a shot.

The process is actually launched here: https://github.com/gradle/gradle/blob/master/subprojects/core/src/main/groovy/org/gradle/process/internal/DefaultWorkerProcess.java#L129

Resolved… after all this time.

The entire thing was a red herring and it turned out to be caused by an application properties file passing in an incorrectly formatted xmx and xms arg into the command line. We discovered this by accident.

Thanks for all your help anyway guys.