stokito / IdeaJol

Intellij plugin that shows an object layout in memory to help optimize it. Uses OpenJDK JOL tool
https://plugins.jetbrains.com/plugin/10953-java-object-layout
Apache License 2.0
142 stars 9 forks source link

IDE freeze with invalid source code causing superclass recursion #32

Open Firestar99 opened 3 years ago

Firestar99 commented 3 years ago

Complete IDE freeze when typing source code and a "superclass recursion" is typed (see example below) and one would right-click -> Show Object Layout. Happened while testing for #29. However as it is invalid source code and noone would actually do this action in normal use feel free to just ignore :)

class Buffer extends Buffer {

}

Thread dump (filtered):

"AWT-EventQueue-0" #30 prio=6 os_prio=0 cpu=42602.66ms elapsed=173.77s tid=0x00007fe06c11a000 nid=0x8c45 runnable  [0x00007fe02c7c0000]
   java.lang.Thread.State: RUNNABLE
        at com.intellij.reference.SoftReference.deref(SoftReference.java:56)
        at com.intellij.psi.impl.source.FileTrees.derefTreeElement(FileTrees.java:71)
        at com.intellij.psi.impl.source.PsiFileImpl.derefTreeElement(PsiFileImpl.java:115)
        at com.intellij.psi.impl.source.PsiFileImpl.getTreeElement(PsiFileImpl.java:104)
        at com.intellij.psi.impl.source.PsiFileImpl.getStubTree(PsiFileImpl.java:618)
        at com.intellij.psi.impl.source.PsiFileImpl.getGreenStubTree(PsiFileImpl.java:952)
        at com.intellij.psi.impl.source.SpineRef.getGreenStub(SpineRef.java:39)
        at com.intellij.extapi.psi.StubBasedPsiElementBase.getGreenStub(StubBasedPsiElementBase.java:352)
        at com.intellij.psi.impl.source.PsiClassImpl.isInterface(PsiClassImpl.java:415)
        at com.intellij.psi.impl.PsiClassImplUtil.getSuperClass(PsiClassImplUtil.java:692)
        at com.intellij.psi.impl.source.PsiClassImpl.getSuperClass(PsiClassImpl.java:200)
        at com.github.stokito.IdeaJol.PsiClassAdapter.addClassFields(PsiClassAdapter.java:41)
        at com.github.stokito.IdeaJol.PsiClassAdapter.createClassDataFromPsiClass(PsiClassAdapter.java:23)
        at com.github.stokito.IdeaJol.toolwindow.JolView.calcClassLayout(JolView.java:242)
        at com.github.stokito.IdeaJol.toolwindow.JolView.showLayoutForSelectedClass(JolView.java:93)
        at com.github.stokito.IdeaJol.toolwindow.JolView.showLayoutForClass(JolView.java:79)
        at com.github.stokito.IdeaJol.toolwindow.JolView.showJolToolWindow(JolView.java:253)
        at com.github.stokito.IdeaJol.ShowObjectLayoutAction.actionPerformed(ShowObjectLayoutAction.java:33)
        at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAware$5(ActionUtil.java:273)
        at com.intellij.openapi.actionSystem.ex.ActionUtil$$Lambda$3019/0x0000000102141040.run(Unknown Source)
        at com.intellij.util.SlowOperations.lambda$allowSlowOperations$0(SlowOperations.java:77)
        at com.intellij.util.SlowOperations$$Lambda$1508/0x00000001015f7840.compute(Unknown Source)
        at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:64)
        at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:76)
        at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:273)
        at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:310)
        at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter$$Lambda$5464/0x00000001030c6440.run(Unknown Source)
        at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:286)
        at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:77)
        at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:299)
        at javax.swing.AbstractButton.fireActionPerformed(java.desktop@11.0.11/AbstractButton.java:1967)
        at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:110)
        at com.intellij.openapi.actionSystem.impl.ActionMenuItem$$Lambda$5461/0x00000001030c7840.run(Unknown Source)
        at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:95)
        at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:110)
        at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:515)
        at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:545)
        at java.awt.Component.processMouseEvent(java.desktop@11.0.11/Component.java:6652)
        at javax.swing.JComponent.processMouseEvent(java.desktop@11.0.11/JComponent.java:3345)
        at java.awt.Component.processEvent(java.desktop@11.0.11/Component.java:6417)
        at java.awt.Container.processEvent(java.desktop@11.0.11/Container.java:2263)
        at java.awt.Component.dispatchEventImpl(java.desktop@11.0.11/Component.java:5027)
        at java.awt.Container.dispatchEventImpl(java.desktop@11.0.11/Container.java:2321)
        at java.awt.Component.dispatchEvent(java.desktop@11.0.11/Component.java:4859)
        at java.awt.LightweightDispatcher.retargetMouseEvent(java.desktop@11.0.11/Container.java:4918)
        at java.awt.LightweightDispatcher.processMouseEvent(java.desktop@11.0.11/Container.java:4547)
        at java.awt.LightweightDispatcher.dispatchEvent(java.desktop@11.0.11/Container.java:4488)
        at java.awt.Container.dispatchEventImpl(java.desktop@11.0.11/Container.java:2307)
        at java.awt.Window.dispatchEventImpl(java.desktop@11.0.11/Window.java:2784)
        at java.awt.Component.dispatchEvent(java.desktop@11.0.11/Component.java:4859)
        at java.awt.EventQueue.dispatchEventImpl(java.desktop@11.0.11/EventQueue.java:778)
        at java.awt.EventQueue$4.run(java.desktop@11.0.11/EventQueue.java:727)
        at java.awt.EventQueue$4.run(java.desktop@11.0.11/EventQueue.java:721)
        at java.security.AccessController.doPrivileged(java.base@11.0.11/Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(java.base@11.0.11/ProtectionDomain.java:85)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(java.base@11.0.11/ProtectionDomain.java:95)
        at java.awt.EventQueue$5.run(java.desktop@11.0.11/EventQueue.java:751)
        at java.awt.EventQueue$5.run(java.desktop@11.0.11/EventQueue.java:749)
        at java.security.AccessController.doPrivileged(java.base@11.0.11/Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(java.base@11.0.11/ProtectionDomain.java:85)
        at java.awt.EventQueue.dispatchEvent(java.desktop@11.0.11/EventQueue.java:748)
        at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:969)
        at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:906)
        at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:836)
        at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:449)
        at com.intellij.ide.IdeEventQueue$$Lambda$417/0x00000001006b3c40.compute(Unknown Source)
        at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:808)
        at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
        at com.intellij.ide.IdeEventQueue$$Lambda$416/0x00000001006b4c40.run(Unknown Source)
        at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:781)
        at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:502)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(java.desktop@11.0.11/EventDispatchThread.java:203)
        at java.awt.EventDispatchThread.pumpEventsForFilter(java.desktop@11.0.11/EventDispatchThread.java:124)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(java.desktop@11.0.11/EventDispatchThread.java:113)
        at java.awt.EventDispatchThread.pumpEvents(java.desktop@11.0.11/EventDispatchThread.java:109)
        at java.awt.EventDispatchThread.pumpEvents(java.desktop@11.0.11/EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.run(java.desktop@11.0.11/EventDispatchThread.java:90)

   Locked ownable synchronizers:
        - None

"JobScheduler FJ pool 4/7" #67 daemon prio=4 os_prio=0 cpu=1838.61ms elapsed=161.61s tid=0x00007fdfe4004000 nid=0x8ca3 runnable  [0x00007fdf76da4000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@11.0.11/Native Method)
        at java.util.concurrent.locks.LockSupport.parkNanos(java.base@11.0.11/LockSupport.java:357)
        at com.intellij.openapi.progress.impl.CoreProgressManager.sleepIfNeededToGivePriorityToAnotherThread(CoreProgressManager.java:862)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.lambda$new$0(ProgressManagerImpl.java:32)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl$$Lambda$361/0x0000000100645440.runHook(Unknown Source)
        at com.intellij.openapi.progress.impl.CoreProgressManager.runCheckCanceledHooks(CoreProgressManager.java:122)
        at com.intellij.openapi.progress.impl.CoreProgressManager.doCheckCanceled(CoreProgressManager.java:137)
        at com.intellij.openapi.progress.ProgressManager.checkCanceled(ProgressManager.java:230)
        at com.intellij.openapi.progress.ProgressIndicatorProvider.checkCanceled(ProgressIndicatorProvider.java:39)
        at com.intellij.extapi.psi.StubBasedPsiElementBase.getGreenStub(StubBasedPsiElementBase.java:350)
        at com.intellij.psi.impl.source.PsiClassImpl.isEnum(PsiClassImpl.java:436)
        at com.intellij.psi.impl.PsiClassImplUtil.getExtendsListTypes(PsiClassImplUtil.java:925)
        at com.intellij.psi.impl.source.PsiClassImpl.getExtendsListTypes(PsiClassImpl.java:185)
        at com.intellij.psi.impl.PsiClassImplUtil.getSuperClass(PsiClassImplUtil.java:711)
        at com.intellij.psi.impl.source.PsiClassImpl.getSuperClass(PsiClassImpl.java:200)
        at org.jetbrains.uast.UClass$DefaultImpls.getSuperClass(UClass.kt:36)
        at org.jetbrains.uast.java.AbstractJavaUClass.getSuperClass(JavaUClass.kt:9)
        at org.jetbrains.uast.java.JavaUClass.getSuperClass(JavaUClass.kt:51)
        at org.jetbrains.uast.java.JavaUClass.getSuperClass(JavaUClass.kt:46)
        at com.github.stokito.IdeaJol.PsiClassAdapter.addClassFields(PsiClassAdapter.java:41)
        at com.github.stokito.IdeaJol.PsiClassAdapter.createClassDataFromPsiClass(PsiClassAdapter.java:23)
        at com.github.stokito.IdeaJol.inspection.JolInspection.checkClass(JolInspection.java:72)
        at com.intellij.codeInspection.AbstractBaseUastLocalInspectionTool$1.visitClass(AbstractBaseUastLocalInspectionTool.java:72)
        at org.jetbrains.uast.UClass$DefaultImpls.accept(UClass.kt:84)
        at org.jetbrains.uast.java.AbstractJavaUClass.accept(JavaUClass.kt:9)
        at com.intellij.uast.UastHintedVisitorAdapter.visitElement(UastHintedVisitorAdapter.kt:21)
        at com.intellij.psi.impl.source.PsiClassImpl.accept(PsiClassImpl.java:462)
        at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:65)
        at com.intellij.codeInspection.InspectionEngine.createVisitorAndAcceptElements(InspectionEngine.java:56)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.runToolOnElements(LocalInspectionsPass.java:320)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$4(LocalInspectionsPass.java:279)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$$Lambda$4471/0x000000010291a040.compute(Unknown Source)
        at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:161)
        at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:153)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$5(LocalInspectionsPass.java:277)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$$Lambda$4466/0x00000001028f1040.compute(Unknown Source)
        at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:132)
        at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:121)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$6(LocalInspectionsPass.java:277)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$$Lambda$4464/0x00000001028f3440.process(Unknown Source)
        at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:136)
        at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:149)
        at com.intellij.concurrency.ApplierCompleter$$Lambda$3943/0x0000000102626840.run(Unknown Source)
        at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1096)
        at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$1(ApplierCompleter.java:92)
        at com.intellij.concurrency.ApplierCompleter$$Lambda$3879/0x00000001025a8c40.run(Unknown Source)
        at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
        at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:64)
        at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:104)
        at com.intellij.concurrency.ApplierCompleter.lambda$compute$0(ApplierCompleter.java:83)
        at com.intellij.concurrency.ApplierCompleter$$Lambda$3942/0x0000000102627440.run(Unknown Source)
        at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:167)
        at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:178)
        at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:83)
        at java.util.concurrent.CountedCompleter.exec(java.base@11.0.11/CountedCompleter.java:746)
        at java.util.concurrent.ForkJoinTask.doExec(java.base@11.0.11/ForkJoinTask.java:290)
        at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(java.base@11.0.11/ForkJoinPool.java:1020)
        at java.util.concurrent.ForkJoinPool.scan(java.base@11.0.11/ForkJoinPool.java:1656)
        at java.util.concurrent.ForkJoinPool.runWorker(java.base@11.0.11/ForkJoinPool.java:1594)
        at java.util.concurrent.ForkJoinWorkerThread.run(java.base@11.0.11/ForkJoinWorkerThread.java:183)

   Locked ownable synchronizers:
        - None
Firestar99 commented 3 years ago

Full thread dump: ThreadDump.txt

stokito commented 3 years ago

thank you for the report, I don't think it worth to fix it due to low possibility of the bug. I'll leave this ticket open and maybe someday I'll fix it