Deadlock running a writeAction inside invokeLater from StartupManager

I get the deadlock between the calls to
ApplicationListener.beforeWriteActionStarted and
ApplicationListener.writeActionStarted (never gets called)

Am I supposed to make sure I do not run SwingUtilities.invokeLater inside the StartupManager.registerStartupActivity ?

Jacques

7 comments
Comment actions Permalink

I guess invokeLater can't be a cause of deadlock. Seems I need some more
info on what you're doing in beforeWriteActionStarted.
One thing that might be a probable cause is showing some modal thing in
write action. Avoid this.

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Jacques Morel" <jacmorel@yahoo.com> wrote in message
news:7059772.1063086960471.JavaMail.itn@is.intellij.net...

I get the deadlock between the calls to
ApplicationListener.beforeWriteActionStarted and
ApplicationListener.writeActionStarted (never gets called)

>

Am I supposed to make sure I do not run SwingUtilities.invokeLater inside

the StartupManager.registerStartupActivity ?
>

Jacques



0
Comment actions Permalink

Thread dump after deadlock. It occurs after
ApplicationListener.beforeWriteActionStart (it gets called)
and before
ApplicationListener.writeActionStarted (it never gets called)
BTW This is for 915. I haven't had time to upgrade yet. Let me know if you need 922 line numbers.

(a java.awt.EventQueue$1AWTInvocationLock) at java.lang.Object.wait(Unknown Source) at java.awt.EventQueue.invokeAndWait(Unknown Source) - locked <0x1008f640> (a java.awt.EventQueue$1AWTInvocationLock) at javax.swing.SwingUtilities.invokeAndWait(Unknown Source) at org.intellij.plugins.util.CommandUtil.runWriteAction(CommandUtil.java:78) at org.intellij.plugins.junit.UntestedMethodHighlighter.markUntestedMethods(UntestedMethodHighlighter.java:98) at org.intellij.plugins.junit.UntestedMethodHighlighter.markUntestedMethodsInEditor(UntestedMethodHighlighter.java:90) at org.intellij.plugins.junit.UntestedMethodHighlighter.mark(UntestedMethodHighlighter.java:147) at org.intellij.plugins.junit.config.JUnitTestConfiguration.updateUntestedMethodHighlighterState(JUnitTestConfiguration.java:98) at org.intellij.plugins.junit.config.JUnitTestConfiguration.updateInternalState(JUnitTestConfiguration.java:81) at org.intellij.plugins.config.Config.configChanged(Config.java:37) at org.intellij.plugins.config.Config$1.run(Config.java:31) at com.intellij.ide.f.a.a.run(a.java:2) at com.intellij.openapi.application.b.d.runReadAction(d.java:24) at com.intellij.ide.f.a.b.b(b.java:15) at com.intellij.openapi.project.b.r.run(r.java:3) at com.intellij.progress.c.a(c.java:52) at com.intellij.openapi.project.b.q.run(q.java:3) at java.lang.Thread.run(Unknown Source) "EditorCaretThread" prio=7 tid=0x02f04d98 nid=0x25cc waiting on condition [78ef000..78efd94] at java.lang.Thread.sleep(Native Method) at com.intellij.openapi.editor.d.dr.run(dr.java:17) "AWT-EventQueue-1" prio=5 tid=0x03c52040 nid=0x2764 in Object.wait() [46af000..46afd94] at java.lang.Object.wait(Native Method) - waiting on <0x11869198> (a com.intellij.util.b.s) at java.lang.Object.wait(Unknown Source) at com.intellij.util.b.s.a(s.java:7) - locked <0x11869198> (a com.intellij.util.b.s) at com.intellij.openapi.application.b.d.runWriteAction(d.java:138) at org.intellij.plugins.util.CommandUtil.runAction(CommandUtil.java:147) at org.intellij.plugins.util.CommandUtil.access$200(CommandUtil.java:15) at org.intellij.plugins.util.CommandUtil$2.run(CommandUtil.java:80) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at com.intellij.ide.s.a(s.java:61) at com.intellij.ide.s.dispatchEvent(s.java:36) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.Dialog$1.run(Unknown Source) at java.awt.Dialog.show(Unknown Source) at com.intellij.openapi.ui.DialogWrapper$MyDialog.show(DialogWrapper.java:21) at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:214) at com.intellij.progress.a.j.run(j.java) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at com.intellij.ide.s.a(s.java:61) at com.intellij.ide.s.dispatchEvent(s.java:36) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) "TimerQueue" daemon prio=5 tid=0x03bcde68 nid=0x2c0c runnable [450f000..450fd94] at java.lang.Object.wait(Native Method) - waiting on <0x11a5f300> (a javax.swing.TimerQueue) at javax.swing.TimerQueue.run(Unknown Source) - locked <0x11a5f300> (a javax.swing.TimerQueue) at java.lang.Thread.run(Unknown Source) "com.jniwrapper.NativeResourceCollector" daemon prio=7 tid=0x03092e90 nid=0x2c30 in Object.wait() [44cf000..44cfd94] at java.lang.Object.wait(Native Method) - waiting on <0x119a4d30> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x119a4d30> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) at com.jniwrapper.NativeResourceCollector$1.run(NativeResourceCollector.java:56) "Thread-1" prio=7 tid=0x039b7718 nid=0x2c34 waiting on condition [447f000..447fd94] at java.lang.Thread.sleep(Native Method) at com.intellij.progress.f.run(f.java:2) "StoreRefreshStatusThread" prio=2 tid=0x0342e940 nid=0x2c38 waiting on condition [433f000..433fd94] at java.lang.Thread.sleep(Native Method) at com.intellij.openapi.vfs.a.b.bk.run(bk.java:4) "WatchForChangesThread" prio=7 tid=0x0304f6b0 nid=0x2c3c runnable [42ff000..42ffd94] at com.intellij.vfs.local.win32.FileWatcher.waitForChangeImpl(Native Method) at com.intellij.vfs.local.win32.FileWatcher.b(FileWatcher.java:7) at com.intellij.openapi.vfs.a.b.bl.run(bl.java:15) "AlarmThread" prio=7 tid=0x031d7020 nid=0x2c40 in Object.wait() [398f000..398fd94] at java.lang.Object.wait(Native Method) - waiting on <0x11909018> (a java.lang.Object) at com.intellij.util.Alarm$MyThread.run(Alarm.java:60) - locked <0x11909018> (a java.lang.Object) "AlarmThread" prio=7 tid=0x031d7a10 nid=0x2c44 in Object.wait() [394f000..394fd94] at java.lang.Object.wait(Native Method) - waiting on <0x11909080> (a java.lang.Object) at java.lang.Object.wait(Unknown Source) at com.intellij.util.Alarm$MyThread.run(Alarm.java:28) - locked <0x11909080> (a java.lang.Object) "License checker" prio=5 tid=0x030bb478 nid=0x2eb0 runnable [36df000..36dfd94] at java.net.PlainDatagramSocketImpl.receive(Native Method) - locked <0x117a6528> (a java.net.PlainDatagramSocketImpl) at java.net.DatagramSocket.receive(Unknown Source) - locked <0x11866028> (a java.net.DatagramPacket) - locked <0x117e76e0> (a java.net.MulticastSocket) at com.intellij.ide.d.g.d(g.java:10) at com.intellij.idea.h.run(h.java:1) at java.lang.Thread.run(Unknown Source) "Java2D Disposer" daemon prio=10 tid=0x030b0eb0 nid=0x2e48 in Object.wait() [369f000..369fd94] at java.lang.Object.wait(Native Method) - waiting on <0x117a3718> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x117a3718> (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) "AWT-Windows" daemon prio=7 tid=0x030a3098 nid=0x2e54 runnable [35bf000..35bfd94] at sun.awt.windows.WToolkit.eventLoop(Native Method) at sun.awt.windows.WToolkit.run(Unknown Source) at java.lang.Thread.run(Unknown Source) "AWT-Shutdown" prio=5 tid=0x030a2e50 nid=0x2e58 in Object.wait() [357f000..357fd94] at java.lang.Object.wait(Native Method) - waiting on <0x11794508> (a java.lang.Object) at java.lang.Object.wait(Unknown Source) at sun.awt.AWTAutoShutdown.run(Unknown Source) - locked <0x11794508> (a java.lang.Object) at java.lang.Thread.run(Unknown Source) "Lock thread" prio=5 tid=0x030539a8 nid=0x2e5c runnable [2dbf000..2dbfd94] at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.PlainSocketImpl.accept(Unknown Source) - locked <0x117945b0> (a java.net.PlainSocketImpl) at java.net.ServerSocket.implAccept(Unknown Source) at java.net.ServerSocket.accept(Unknown Source) at com.intellij.idea.p.run(p.java:5) at java.lang.Thread.run(Unknown Source) "DestroyJavaVM" prio=5 tid=0x00036f20 nid=0x2e10 waiting on condition [0..7fae0] "Signal Dispatcher" daemon prio=10 tid=0x0003ef30 nid=0x2e78 waiting on condition [0..0] "Finalizer" daemon prio=9 tid=0x009bcea8 nid=0x2e00 in Object.wait() [2c3f000..2c3fd94] at java.lang.Object.wait(Native Method) - waiting on <0x11735918> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x11735918> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source) "Reference Handler" daemon prio=10 tid=0x009bba78 nid=0x2e08 in Object.wait() [2bff000..2bffd94] at java.lang.Object.wait(Native Method) - waiting on <0x11735980> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Unknown Source) at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source) - locked <0x11735980> (a java.lang.ref.Reference$Lock) "VM Thread" prio=5 tid=0x009f76f8 nid=0x2e0c runnable "VM Periodic Task Thread" prio=10 tid=0x009f9748 nid=0x2e7c waiting on condition "Suspend Checker Thread" prio=10 tid=0x0003e5e8 nid=0x2e70 runnable ]]>

This is a trace I put in the JUnitTestPlugin because we had some NPE inside this method. The interesting thing is that it seems that the deadlock occurs when I get a PsiClass with a null superclass. Is that normal BTW?

Also the startup activities seem to run inside a read action. Is that right? Can a thread starts with a read action and switch to a write action in the middle?

Here is the stacktrace. PsiClassManagerTest is one of the previously opened class in the editor.



Thanks Maxim for your help. I am not sure how I can provide more information. Let me know.

Jacques

0
Comment actions Permalink

This still happens in 922.
The only thing that happens in the startup activity that is remotely graphical is the creation of icons in the gutter of opened editors.

0
Comment actions Permalink

I just read my previous post and some text got lost:

The interesting piece of data is that the deadlock seems to occur always when the plugin gets a PsiClass object that does not have a superclass. Is that supposed to happen? Would that indicate a race condition/corruption in the proper initialization of the PSI tree.

BTW when I upgraded to 922 I wiped clean my system directory and that did not have any effect.

Jacques

0
Comment actions Permalink

Can I see the sources? I see some illegal operations with
invokeAndWait+runWriteAction from the stacktraces but can't say what should
be fixed exactly without seeing the code.

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Jacques Morel" <jacmorel@yahoo.com> wrote in message
news:31035049.1063207521113.JavaMail.itn@is.intellij.net...

This still happens in 922.
The only thing that happens in the startup activity that is remotely

graphical is the creation of icons in the gutter of opened editors.


0
Comment actions Permalink

It would have helped if I had been more accurate on my use "invokeLater" which was in fact, like you saw, "invokeAndWait".
Such an insignificant little detail. You would not hold this against me, would you ;)

0

Please sign in to leave a comment.