Deadlock on Linux [Solved]

I use the default threading model of JOGl to do my rendering and on windows my program works as expected.
Today I tried it on Linux and I get a deadlock. Any solutions?

[quote=“numknuf,post:1,topic:28685”]
Fix the deadlock? :wink:

Start the app from the commandline, and when it deadlocks hit ctrl+. You’ll get a stack dump and simple deadlocks will be identified.

This is my deadlock:

Java stack information for the threads listed above:

“AWT-EventQueue-0”:
at java.awt.Component.invalidate(Component.java:2432)
- waiting to lock <0x00002aaab6df4ef0> (a java.awt.Component$AWTTreeLock)
at java.awt.Container.invalidate(Container.java:1419)
at javax.swing.JComponent.revalidate(JComponent.java:4573)
at javax.swing.JLabel.setText(JLabel.java:320)
at components.RenderingPanel.display(RenderingPanel.java:197)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:298)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

“main”:
at sun.misc.Unsafe.monitorEnter(Native Method)
at sun.awt.X11.XToolkit.awtLock(XToolkit.java:191)
at sun.awt.X11.XDecoratedPeer.reshape(XDecoratedPeer.java:310)
at sun.awt.X11.XDecoratedPeer.reshape(XDecoratedPeer.java:403)
at sun.awt.X11.XDecoratedPeer.setBounds(XDecoratedPeer.java:411)
at java.awt.Component.reshapeNativePeer(Component.java:1924)
at java.awt.Component.reshape(Component.java:1880)
- locked <0x00002aaab6df4ef0> (a java.awt.Component$AWTTreeLock)
at java.awt.Component.setBounds(Component.java:1847)
at java.awt.Window.setBounds(Window.java:2342)
- locked <0x00002aaab6df4ef0> (a java.awt.Component$AWTTreeLock)
at java.awt.Window.setClientSize(Window.java:502)
- locked <0x00002aaab6df4ef0> (a java.awt.Component$AWTTreeLock)
at java.awt.Window.pack(Window.java:488)
at volume.viewer.SonarExplorer.(SonarExplorer.java:132)
at volume.viewer.SonarExplorer.main(SonarExplorer.java:561)
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:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

Found 1 deadlock.

Hmmm, not seen one like that before…

Instead of calling pack() in the constructor of your SonarExplorer directly, try it like this:


SwingUtilities.invokeLater( new Runnable()
{
   public void run()
   {
      SonarExplorer.this.pack();
   }
} );

This will cause the pack() call to be executed on the AWTEvent thread, so there’s no chance of this deadlock occurring.
Hope this helps.

Thanks!

I had to move some other methods in there too but it solved it. :slight_smile: