Daemon code analyzer deadlock

One of my co-workers is having a problem with a plugin I have written for IDEA to help manage the logging i18n resource files for our project, which is causing a deadlock with the "Daemon code analyzer" thread. He's using a multi-CPU machine and running IDEA 6.0.5.

Here are the stacktraces for the threads which are deadlocked:

"Daemon code analyzer" prio=2 tid=0x324b1788 nid=0xab0 waiting for monitor entry
at com.intellij.psi.impl.source.tree.CompositeElement.findChildByRoleAsPsiElement(CompositeElement.java:172)
- waiting to lock (a java.lang.Object) at com.intellij.psi.impl.source.PsiClassImpl.getTypeParameterList(PsiClassImpl.java:177) at com.intellij.psi.impl.PsiImplUtil.getTypeParameters(PsiImplUtil.java:104) at com.intellij.psi.impl.source.PsiClassImpl.getTypeParameters(PsiClassImpl.java:264) at com.intellij.psi.util.PsiUtil$TypeParameterIterator.obtainCurrentParams(PsiUtil.java:1024) at com.intellij.psi.util.PsiUtil$TypeParameterIterator.(PsiUtil.java:1019) at com.intellij.psi.util.PsiUtil$TypeParameterIterator.(PsiUtil.java:1009) at com.intellij.psi.util.PsiUtil.typeParametersIterator(PsiUtil.java:1068) at com.intellij.psi.util.PsiUtil.isRawSubstitutor(PsiUtil.java:1116) at com.intellij.psi.impl.PsiClassImplUtil.a(PsiClassImplUtil.java:192) at com.intellij.psi.impl.PsiClassImplUtil.a(PsiClassImplUtil.java:179) at com.intellij.psi.impl.PsiClassImplUtil.processDeclarationsInClassNotCached(PsiClassImplUtil.java:169) at com.intellij.psi.impl.PsiClassImplUtil.processDeclarationsInClass(PsiClassImplUtil.java:38) at com.intellij.psi.impl.source.PsiClassImpl.processDeclarations(PsiClassImpl.java:210) at com.intellij.psi.scope.util.PsiScopesUtil.processScope(PsiScopesUtil.java:33) at com.intellij.psi.scope.util.PsiScopesUtil.treeWalkUp(PsiScopesUtil.java:112) at com.intellij.psi.scope.util.PsiScopesUtil.resolveAndWalk(PsiScopesUtil.java:24) at com.intellij.psi.scope.util.PsiScopesUtil.resolveAndWalk(PsiScopesUtil.java:76) at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.b(PsiJavaCodeReferenceElementImpl.java:143) at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.access$000(PsiJavaCodeReferenceElementImpl.java:68) at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl$OurGenericsResolver._resolve(PsiJavaCodeReferenceElementImpl.java:25) at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl$OurGenericsResolver.resolve(PsiJavaCodeReferenceElementImpl.java:4) at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl$OurGenericsResolver.resolve(PsiJavaCodeReferenceElementImpl.java:9) at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:117) at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.multiResolve(PsiJavaCodeReferenceElementImpl.java:320) at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.advancedResolve(PsiJavaCodeReferenceElementImpl.java:101) at com.intellij.psi.impl.source.PsiClassReferenceType.resolveGenerics(PsiClassReferenceType.java:22) at com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl.multiResolveConstructor(PsiResolveHelperImpl.java:159) at com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl.resolveConstructor(PsiResolveHelperImpl.java:193) at com.intellij.psi.impl.source.tree.java.PsiNewExpressionImpl.resolveMethodGenerics(PsiNewExpressionImpl.java:108) at com.intellij.codeInsight.ExceptionUtil.getUnhandledExceptions(ExceptionUtil.java:94) at com.intellij.codeInsight.ExceptionUtil.a(ExceptionUtil.java:132) at com.intellij.codeInsight.ExceptionUtil.collectUnhandledExceptions(ExceptionUtil.java:175) at com.intellij.psi.controlFlow.ControlFlowAnalyzer.d(ControlFlowAnalyzer.java:724) at com.intellij.psi.controlFlow.ControlFlowAnalyzer.visitNewExpression(ControlFlowAnalyzer.java:652) at com.intellij.psi.impl.source.tree.java.PsiNewExpressionImpl.accept(PsiNewExpressionImpl.java:87) at com.intellij.psi.controlFlow.ControlFlowAnalyzer.visitField(ControlFlowAnalyzer.java:617) at com.intellij.psi.impl.source.PsiFieldImpl.accept(PsiFieldImpl.java:118) at com.intellij.psi.controlFlow.ControlFlowAnalyzer.buildControlFlow(ControlFlowAnalyzer.java:241) at com.intellij.psi.controlFlow.ControlFlowFactory.getControlFlow(ControlFlowFactory.java:46) - locked <0x0d99f968>]]> (a com.intellij.psi.impl.source.PsiFieldImpl)
at com.intellij.psi.controlFlow.ControlFlowFactory.getControlFlow(ControlFlowFactory.java:16)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil.a(HighlightControlFlowUtil.java:321)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil.a(HighlightControlFlowUtil.java:236)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil.a(HighlightControlFlowUtil.java:233)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil.checkFinalFieldInitialized(HighlightControlFlowUtil.java:262)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitField(HighlightVisitorImpl.java:145)
at com.intellij.psi.impl.source.PsiFieldImpl.accept(PsiFieldImpl.java:118)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visit(HighlightVisitorImpl.java:121)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:23)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.doCollectInformation(GeneralHighlightingPass.java:20)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:59)
at com.intellij.codeInsight.daemon.impl.UpdateThread$2.run(UpdateThread.java:0)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:271)
at com.intellij.codeInsight.daemon.impl.UpdateThread.a(UpdateThread.java:18)
at com.intellij.codeInsight.daemon.impl.UpdateThread.access$100(UpdateThread.java:2)
at com.intellij.codeInsight.daemon.impl.UpdateThread$1.run(UpdateThread.java:1)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:51)
at com.intellij.codeInsight.daemon.impl.UpdateThread.run(UpdateThread.java:23)


"AWT-EventQueue-1" prio=6 tid=0x2954e7b0 nid=0x9fc waiting for monitor entry
at com.intellij.psi.impl.source.SrcRepositoryPsiElement.getTreeElement(SrcRepositoryPsiElement.java:80)
- waiting to lock (a com.intellij.psi.impl.source.PsiFieldImpl) at com.intellij.psi.impl.source.PsiFieldImpl.b(PsiFieldImpl.java:161) at com.intellij.psi.impl.source.PsiFieldImpl.getModifierList(PsiFieldImpl.java:13) at com.intellij.psi.impl.cache.impl.repositoryCache.RecordManager.createClass(RecordManager.java:197) at com.intellij.psi.impl.cache.impl.repositoryCache.RecordManager.a(RecordManager.java:89) at com.intellij.psi.impl.cache.impl.repositoryCache.RecordManager.createFile(RecordManager.java:80) at com.intellij.psi.impl.cache.impl.repositoryCache.RepositoryCache$5.run(RepositoryCache.java:10) at com.intellij.psi.impl.cache.impl.repositoryCache.RepositoryCache.a(RepositoryCache.java:312) - locked <0x06907460> (a java.lang.Object) at com.intellij.psi.impl.cache.impl.repositoryCache.RepositoryCache.fileCreated(RepositoryCache.java:138) at com.intellij.psi.impl.cache.impl.RepositoryManagerImpl.a(RepositoryManagerImpl.java:377) - locked <0x06907460>]]> (a java.lang.Object)
at com.intellij.psi.impl.cache.impl.RepositoryManagerImpl.updateAll(RepositoryManagerImpl.java:131)
at com.intellij.psi.impl.cache.impl.RepositoryIndexImpl.getClassesByQualifiedName(RepositoryIndexImpl.java:8)
at com.intellij.psi.impl.file.impl.FileManagerImpl.a(FileManagerImpl.java:213)
at com.intellij.psi.impl.file.impl.FileManagerImpl.findClass(FileManagerImpl.java:104)
at com.intellij.psi.impl.PsiManagerImpl$PsiElementFinderImpl.findClass(PsiManagerImpl.java:29)
at com.intellij.psi.impl.PsiManagerImpl.findClass(PsiManagerImpl.java:254)
at com.quest.ideaplugins.Utils.getClassForType(Utils.java:108)
at com.quest.ideaplugins.i18nplugin.model.CatParser.parseCATField(CatParser.java:144)
at com.quest.ideaplugins.i18nplugin.model.CatParser.parseClass(CatParser.java:65)
at com.quest.ideaplugins.i18nplugin.model.CatParser.parseFile(CatParser.java:57)
at com.quest.ideaplugins.i18nplugin.view.CatListPanel.updateTableModel(CatListPanel.java:240)
at com.quest.ideaplugins.i18nplugin.view.CatListPanel.updateContents(CatListPanel.java:201)
at com.quest.ideaplugins.i18nplugin.view.CatListPanel.refresh(CatListPanel.java:191)
at com.quest.ideaplugins.i18nplugin.view.CatListPanel$1.actionPerformed(CatListPanel.java:82)
at javax.swing.Timer.fireActionPerformed(Timer.java:271)
at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:126)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:153)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:124)
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)


My plugin is the com.quest.ideaplugins.i18nplugin package in the AWT-EventQueue-1 thread. It's processing a Swing Timer event that I start after receiving a documentChanged notification for the current document. It's rescanning the document for references to our logging system and building up a list of log messages used to be displayed in a toolwindow. This can be an expensive process and I didn't want to do it "inline" for every documentChanged notification because it caused some bad interface lag, so it restarts the timer for every change and thus will only process the changes when the user pauses for 500ms.

According to the plugin documentation, performing "read actions" through the PSI is valid on the Swing event thread, so I'm not sure what I'm doing incorrectly here.

3 comments

Should I file a JIRA issue for this?

0

Hello Gordon,

there are a couple of similar looking issues already:

http://www.jetbrains.net/jira/browse/IDEADEV-12593
http://www.jetbrains.net/jira/browse/IDEADEV-13169

I think you should try to upgrade to 6.0.6 or even 7.0 (which looks like it is unable to deadlock at this position at all)

Sascha

0

Thanks, Sascha, I didn't know there was a IDEA 6.0.6. We'll try that out now.

0

Please sign in to leave a comment.