PDA

View Full Version : JVM won't die after shader compile



Jeffg
11-10-2010, 01:20 PM
I have a Windows 7 machine (ATI HD3470), that runs a jogl app and the app exits fine (as far as closing it from the screen). However, the JVM is not terminating in the background. It stays active then jumps to 100% cpu on a core. I've isolate the piece of code that's causing the issue.

gl.glCompileShaderARB(vertexShader);

But the shaders are working just fine. The glGetInfoLog reports that the shader compiled successfully. But for some reason, when I exit the application, the JVM won't terminate.

I've tried this... but it doesn't help.

gl.glUseProgramObjectARB(0);
gl.glDetachObjectARB(programObject, vertexShader);
gl.glDeleteObjectARB(vertexShader);
gl.glDetachObjectARB(programObject, fragmentShader);
gl.glDeleteObjectARB(fragmentShader);
gl.glDeleteObjectARB(programObject);

ZbuffeR
11-10-2010, 01:54 PM
Are you using any non-daemon threads ?
After closing the window and having jvm at 100% of one core, run a jstack on its pid, store the result as file, do it a few times, you will have a good idea of the infinite loop which is running ...

Jeffg
11-10-2010, 05:38 PM
I haven't created any additional threads and it works fine on most machines, even works on a VMWare Windows 7 machine fine. But for some reason (and I've installed the latest Java) this particular ATI card (running the latest drivers) is giving me an issue. Even a halt() doesn't kill the JVM.

Runtime.getRuntime().halt(1);

It's not stuck in a loop. It finishes everything fine and gets to the System.exit() without issue. Something with the glCompileShader is creating a lock that won't let the JVM close. I can do an exit() right up to the point I compile the shader, any point after that and it will not exit the JVM. I'll give a look at jstack on Friday.

Jeffg
11-12-2010, 12:52 PM
Ok.. I got it to die.. but perhaps someone could give me some advice on minimizing the potential damage I may be doing, if any. Here is what I had to do.

System.exit(0);

try {
if (OS.startsWith("Windows")) {
String pidstr = java.lang.management.ManagementFactory.getRuntimeM XBean().getName();
String pid[] = pidstr.split("@");
Runtime.getRuntime().exec("taskkill /F /PID " + pid[0]).waitFor();
}
}
catch (Exception e) {
}

ZbuffeR
11-12-2010, 03:04 PM
Yeah well to know what damage it would have caused, I would have been nice the see those jstacks ... wink wink nudge nudge ;)

Jeffg
11-15-2010, 08:03 AM
Ok.. ran jstack. It runs fine when the program is running (output is below). If I close the application (JVM still running because it won't close), jstack gives me "Access Denied".

Here is the output of the running application:

2010-11-15 10:04:04
Full thread dump Java HotSpot(TM) Client VM (17.1-b03 mixed mode):

"Direct Clip" daemon prio=6 tid=0x4a414400 nid=0xaf8 in Object.wait() [0x4f75f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x19933720> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x19933720> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4a413c00 nid=0x25c in Object.wait() [0x4f70f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x19933840> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x19933840> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4a413800 nid=0x930 in Object.wait() [0x4f6bf000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x19933960> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x19933960> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4a413000 nid=0x6ec in Object.wait() [0x4f5ff000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x19933a80> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x19933a80> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4a412c00 nid=0x5d8 in Object.wait() [0x4f56f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x19933ba0> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x19933ba0> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4a412400 nid=0x7c8 in Object.wait() [0x4f51f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x19922d50> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x19922d50> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4a412000 nid=0x658 in Object.wait() [0x4e59f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x198c3958> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x198c3958> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4a411800 nid=0xd00 in Object.wait() [0x4e54f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x198c3a78> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x198c3a78> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4a014400 nid=0x3bc in Object.wait() [0x4e4ff000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x198c3b98> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x198c3b98> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4a1e3800 nid=0xd40 in Object.wait() [0x4e4af000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x198c3cb8> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x198c3cb8> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Direct Clip" daemon prio=6 tid=0x4f7dbc00 nid=0x7ac in Object.wait() [0x4e45f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x198c3dd8> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.DirectAudioDevice$DirectClip.r un(Unknown Source)
- locked <0x198c3dd8> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Java Sound Event Dispatcher" daemon prio=6 tid=0x4a424400 nid=0xb44 in Object.wait() [0x4dcff000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x198c3ef8> (a com.sun.media.sound.EventDispatcher)
at java.lang.Object.wait(Object.java:485)
at com.sun.media.sound.EventDispatcher.dispatchEvents (Unknown Source)
- locked <0x198c3ef8> (a com.sun.media.sound.EventDispatcher)
at com.sun.media.sound.EventDispatcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"DestroyJavaVM" prio=6 tid=0x01951c00 nid=0x8cc waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
- None

"D3D Screen Updater" daemon prio=8 tid=0x4a065400 nid=0xce4 in Object.wait() [0x4f03f000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at sun.java2d.d3d.D3DScreenUpdateManager.run(Unknown Source)
- locked <0x190c39a8> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Animation Thread" prio=6 tid=0x49f73800 nid=0xd88 runnable [0x4efef000]
java.lang.Thread.State: RUNNABLE
at com.sun.opengl.impl.windows.WGL.SwapBuffers(Native Method)
at com.sun.opengl.impl.windows.WindowsOnscreenGLDrawa ble.swapBuffers(WindowsOnscreenGLDrawable.java:131 )
at processing.opengl.PGraphicsOpenGL.endDraw(PGraphic sOpenGL.java:345)
at processing.core.PApplet.handleDraw(PApplet.java:16 27)
at processing.core.PApplet.run(PApplet.java:1503)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"AWT-EventQueue-0" prio=6 tid=0x49f4fc00 nid=0xf60 in Object.wait() [0x4d84f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x190575a8> (a java.awt.EventQueue)
at java.lang.Object.wait(Object.java:485)
at java.awt.EventQueue.getNextEvent(Unknown Source)
- locked <0x190575a8> (a java.awt.EventQueue)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Locked ownable synchronizers:
- None

"AWT-Windows" daemon prio=6 tid=0x4a0bdc00 nid=0x938 runnable [0x4a76f000]
java.lang.Thread.State: RUNNABLE
at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"AWT-Shutdown" prio=6 tid=0x49fa1400 nid=0xa34 in Object.wait() [0x4a56f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x190101b0> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at sun.awt.AWTAutoShutdown.run(Unknown Source)
- locked <0x190101b0> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Java2D Disposer" daemon prio=10 tid=0x49f18400 nid=0x394 in Object.wait() [0x4a51f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x19010248> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x19010248> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at sun.java2d.Disposer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"Low Memory Detector" daemon prio=6 tid=0x01a1a400 nid=0xb74 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
- None

"CompilerThread0" daemon prio=10 tid=0x01a00c00 nid=0xbe4 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
- None

"Attach Listener" daemon prio=10 tid=0x019fb000 nid=0xc14 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
- None

"Signal Dispatcher" daemon prio=10 tid=0x019f7c00 nid=0xc04 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:
- None

"Finalizer" daemon prio=8 tid=0x019cd000 nid=0x3e4 in Object.wait() [0x49d3f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x190104a0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x190104a0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknow n Source)

Locked ownable synchronizers:
- None

"Reference Handler" daemon prio=10 tid=0x019c8800 nid=0xa8 in Object.wait() [0x49cef000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x19010530> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:485)
at java.lang.ref.Reference$ReferenceHandler.run(Unkno wn Source)
- locked <0x19010530> (a java.lang.ref.Reference$Lock)

Locked ownable synchronizers:
- None

"VM Thread" prio=10 tid=0x019c6000 nid=0x51c runnable

"VM Periodic Task Thread" prio=10 tid=0x01a1bc00 nid=0xd44 waiting on condition

JNI global references: 2004

ZbuffeR
11-15-2010, 08:25 AM
Not used to jstack on windows, but you may have to run it with admin privileges, and/or use option -F to force the dump ?

Jeffg
11-15-2010, 08:30 AM
I did run it with admin privileges and there is no -F option on Windows.

Perhaps this is some new security in Windows 7 that is preventing a proper close of the JVM?

ZbuffeR
11-15-2010, 09:01 AM
Hard to say, as this intersects multiple things :
- Windows 7
- jogl bindings to GL
- ATI GL driver
http://jogamp.762907.n3.nabble.com/JVM-won-t-die-after-shader-compile-td1877330.html

I am doubtful about a new security in windows 7 ...

Jeffg
11-15-2010, 09:10 AM
Correction above.. I didn't have System.exit(0) before my "taskkill" as I never needed System.exit() in the past as it closed normally. If I do put in System.exit(0) before my taskkill, the taskkill never runs but the JVM doesn't shut down either. Runtime.getRuntime().halt(1) didn't work either. So something is happening locking up the actual Java Shutdown due to the glCompileShader.

I posted this issue in the JOGL forum as well as it may be specific to them.

fred_em
11-19-2010, 07:24 AM
Jeffg,

I have a very similar issue. I also have a Java application. I don't use JOGL but use OSG through a JNI layer.

My application either doesn't stop just like in your case, or takes a very long time to stop (15-20 seconds).

The hang happens at process-detach time, things seem to be pretty much out of my control at that point.

I have started a thread on an AMD forum but haven't got any answer so far:

"Long delay in wglDeleteContext on application exit"
http://forums.amd.com/devforum/messageview.cfm?catid=392&amp;threadid=141999&amp;enterthr ead=y

My configuration: ATI Mobility Radeon HD5470, Windows 7 x64, Catalyst 10.10 or 10.11 drivers