We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › In eclipse, I cannot debug an unpredictable freeze
Page Index Toggle Pages: 1
In eclipse, I cannot debug an unpredictable freeze (Read 3061 times)
In eclipse, I cannot debug an unpredictable freeze
Aug 31st, 2009, 5:40pm
 
Hi!

I've been struggling for two weeks trying to find out what is causing my processing - based program to freeze without luck, so I thought I'd resort to asking you all in case you can give me a hint in the right direction!

It's a bit more advanced java, a bit outside the "normal" realm of processing.

My program freezes randomly between either a minute or more than two hours of running time. What is worse, when in the eclipse debugger I click pause to see if my program is deadlocked, and get the following error in eclipse:

"org.eclipse.jdi.TimeoutException: Timeout occurred while waiting for packet XXXX. occurred resuming thread."

and the debugger cannot possibly stop the program from running.

All the while, I can see that it is running at 40-50% of my available cpu power (on a dual core machine).

Finally using the lovely SendSignal program, I managed to send my frozen program a Ctrl-Break request to produce a stack trace. In that, two threads are reported as blocked:

"TimerQueue" daemon prio=6 tid=0x0c461c00 nid=0x1764 in Object.wait() [0x0d78f000]
java.lang.Thread.State: BLOCKED (on object monitor)
at java.lang.Object.wait(Native Method)
at javax.swing.TimerQueue.run(TimerQueue.java:236)
- locked <0x03016810> (a javax.swing.TimerQueue)
at java.lang.Thread.run(Thread.java:619)


....

"Animation Thread" prio=6 tid=0x0b5c2800 nid=0x1140 waiting for monitor entry [0x0b99f000]
java.lang.Thread.State: BLOCKED (on object monitor)
at sun.java2d.d3d.D3DScreenUpdateManager.trackScreenSurface(D3DScreenUpdateManager.
java:286)
- waiting to lock <0x02ebde78> (a sun.java2d.d3d.D3DScreenUpdateManager)
at sun.java2d.d3d.D3DScreenUpdateManager.createGraphics(D3DScreenUpdateManager.java
:254)
at sun.awt.windows.WComponentPeer.getGraphics(WComponentPeer.java:524)
at java.awt.Component.getGraphics(Component.java:2819)
at processing.core.PApplet.paint(PApplet.java:1275)
at processing.core.PApplet.handleDraw(PApplet.java:1456)
at processing.core.PApplet.run(PApplet.java:1328)
at java.lang.Thread.run(Thread.java:619)

All other threads are either runnable or waiting.

Does this look familiar to any of you?

In case you're curious, the program I'm debugging is Mother, which I've made for VJ-ing with multiple processing sketches (see www.onar3d.com and onar3d.com/mother for more info).

Thank you!
Re: In eclipse, I cannot debug an unpredictable freeze
Reply #1 - Sep 1st, 2009, 1:35am
 
Is your application multi-threaded? Looks like a deadlock on accessing resources, although it might happen at low level.
I see also you use javax.swing.TimerQueue (explicitly?) and I have seen that Swing doesn't mix well with Processing (problems of threading, IIRC).
Lastly, I see a lock on sun.java2d.d3d.D3DScreenUpdateManager, perhaps you can make your application to run with OpenGL instead?
You can run your sketch with -Dsun.java2d.opengl=true on the command line. I know that on my low end computer, I have a much better framerate (in 2D) than with default settings (with JGears, I haven't tried with Processing).
Re: In eclipse, I cannot debug an unpredictable freeze
Reply #2 - Sep 1st, 2009, 3:36am
 
Hi, thank you for your quick reply!

I'm using the timing framework in my program: https://timingframework.dev.java.net/ - which in turn uses javax.swing.Timer, I assume timerqueue is thus implicitly loaded by this timing framework.

My application is implicitly multithreaded, i.e. the oscp5 library has it's own threads, the timingframework it's own, and Processing it's own. I do not explicitly create any threads myself.

Finally, adding -Dsun.java2d.opengl=true to an OPENGL-enabled processing sketch crashes with the following dump before it fully loads:

Exception in thread "Animation Thread" javax.media.opengl.GLException: wglShareLists(0x10001, 0x10002) failed: error code 0
     at com.sun.opengl.impl.windows.WindowsGLContext.create(WindowsGLContext.java:136)
     at com.sun.opengl.impl.windows.WindowsGLContext.makeCurrentImpl(WindowsGLContext.ja
va:150)
     at com.sun.opengl.impl.windows.WindowsOnscreenGLContext.makeCurrentImpl(WindowsOnsc
reenGLContext.java:66)
     at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)
     at processing.opengl.PGraphicsOpenGL.detainContext(PGraphicsOpenGL.java:229)
     at processing.opengl.PGraphicsOpenGL.beginDraw(PGraphicsOpenGL.java:274)
     at processing.core.PApplet.handleDraw(PApplet.java:1393)
     at processing.core.PApplet.run(PApplet.java:1328)
     at java.lang.Thread.run(Thread.java:619)

Thank you for your tips, I'll follow them up and see where it gets me!
Re: In eclipse, I cannot debug an unpredictable freeze
Reply #3 - Sep 1st, 2009, 10:25am
 
I replaced the timingframework with the processing-specific shapetween library so as to get rid of any swing references.

The program still freezes like it used to though.

I forgot to mention that I'm using Processing v1.0.6, and jdk1.6.0_16, along with the latest versions of all libraries used.

Also now I do not get any stacktrace when it's frozen, neither using
SendSignal nor jStack -l.

What I've discovered is that if AFTER having sent the Ctrl-Break message with SendSignal, I edit my main class in eclipse and save the change with the program still running, I do get a stacktrace, as the class is reloaded in by eclipse. Weird but it works, only thing is I cannot be sure what state the contents of the stacktrace represent.

Any other ideas as to what it may be I'm up against? :)

Thank you!
Ilias B.
Re: In eclipse, I cannot debug an unpredictable freeze
Reply #4 - Sep 1st, 2009, 10:34am
 
I forgot to mention, this time around there was only one blocked thread:

"Reference Handler" daemon prio=10 tid=0x0aaa5000 nid=0x3090 in Object.wait() [0x0abcf000]
  java.lang.Thread.State: BLOCKED (on object monitor)
     at java.lang.Object.wait(Native Method)
     at java.lang.Object.wait(Object.java:485)
     at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
     - locked <0x02e8a228> (a java.lang.ref.Reference$Lock)

...I'll defy the boycott Google day and give it a good search in case anyone has posted about anything similar...

Thanks!
Page Index Toggle Pages: 1