Haehnchen / idea-php-toolbox

Collections of tools and improvements to make PhpStorm a little bit better
http://phpstorm.espend.de/php-toolbox
MIT License
158 stars 20 forks source link

Freeze in PhpStorm #107

Open bzixilu opened 1 year ago

bzixilu commented 1 year ago

Freeze for 187 seconds IDE KILLED! Sampled time: 141600ms, sampling rate: 100ms, GC time: 1287ms (0%), Class loading: 0%, cpu load: 0%

The stack is from the thread that was blocking EDT

com.intellij.diagnostic.Freeze at java.base@17.0.5/jdk.internal.misc.Unsafe.park(Native Method) at java.base@17.0.5/java.util.concurrent.locks.LockSupport.park(LockSupport.java:211) at java.base@17.0.5/java.util.concurrent.Phaser$QNode.block(Phaser.java:1133) at java.base@17.0.5/java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3463) at java.base@17.0.5/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3434) at java.base@17.0.5/java.util.concurrent.Phaser.internalAwaitAdvance(Phaser.java:1063) at java.base@17.0.5/java.util.concurrent.Phaser.awaitAdvance(Phaser.java:725) at com.intellij.util.indexing.events.ChangedFilesCollector.processFilesInReadAction(ChangedFilesCollector.java:293) at com.intellij.util.indexing.events.ChangedFilesCollector.processFilesToUpdateInReadAction(ChangedFilesCollector.java:224) at com.intellij.util.indexing.FileBasedIndexScanUtil.ensureUpToDate(FileBasedIndexScanUtil.java:51) at com.intellij.util.indexing.FileBasedIndexScanUtil.processFilesContainingAnyKey(FileBasedIndexScanUtil.java:237) at com.intellij.util.indexing.FileBasedIndexImpl.processFilesContainingAnyKey(FileBasedIndexImpl.java:1178) at com.intellij.psi.search.FilenameIndex.getVirtualFilesByNames(FilenameIndex.java:225) at com.intellij.psi.search.FilenameIndex.processFilesByNames(FilenameIndex.java:155) at com.intellij.psi.search.FilenameIndex.processFilesByName(FilenameIndex.java:131) at com.intellij.psi.search.FilenameIndex.processFilesByName(FilenameIndex.java:95) at com.intellij.psi.search.FilenameIndex.getFilesByName(FilenameIndex.java:183) at com.intellij.psi.search.FilenameIndex.getFilesByName(FilenameIndex.java:85) at de.espend.idea.php.toolbox.utils.ExtensionProviderUtil.lambda$getJsonConfigs$6(ExtensionProviderUtil.java:223) at de.espend.idea.php.toolbox.utils.ExtensionProviderUtil$$Lambda$8689/0x000000008258c958.compute(Unknown Source) at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:39) at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:243) at com.intellij.util.CachedValueBase$$Lambda$2170/0x0000000081431198.compute(Unknown Source) at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42) at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:243) at com.intellij.util.CachedValueBase$$Lambda$2169/0x0000000081430f28.compute(Unknown Source) at com.intellij.openapi.util.RecursionGuard$$Lambda$2050/0x00000000813a3b28.compute(Unknown Source) at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:112) at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:42) at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:66) at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:244) at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:28) at de.espend.idea.php.toolbox.utils.ExtensionProviderUtil.getJsonConfigs(ExtensionProviderUtil.java:240) at de.espend.idea.php.toolbox.utils.ExtensionProviderUtil.getTypesInner(ExtensionProviderUtil.java:177) at de.espend.idea.php.toolbox.utils.ExtensionProviderUtil.lambda$getTypes$3(ExtensionProviderUtil.java:161) at de.espend.idea.php.toolbox.utils.ExtensionProviderUtil$$Lambda$6473/0x00000000820e8240.compute(Unknown Source) at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:39) at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:243) at com.intellij.util.CachedValueBase$$Lambda$2170/0x0000000081431198.compute(Unknown Source) at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42) at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:243) at com.intellij.util.CachedValueBase$$Lambda$2169/0x0000000081430f28.compute(Unknown Source) at com.intellij.openapi.util.RecursionGuard$$Lambda$2050/0x00000000813a3b28.compute(Unknown Source) at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:112) at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:42) at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:66) at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:244) at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:28) at de.espend.idea.php.toolbox.utils.ExtensionProviderUtil.getTypes(ExtensionProviderUtil.java:166) at de.espend.idea.php.toolbox.type.PhpToolboxTypeProvider.getType(PhpToolboxTypeProvider.java:49) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.lambda$getTypeFromAST$1(PhpTypeInfo.java:102) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo$$Lambda$5625/0x0000000081f7a210.compute(Unknown Source) at com.intellij.openapi.util.RecursionGuard$$Lambda$2050/0x00000000813a3b28.compute(Unknown Source) at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:112) at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:42) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getTypeFromAST(PhpTypeInfo.java:78) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getTypeCached(PhpTypeInfo.java:61) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getType(PhpTypeInfo.java:43) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getType(PhpTypeInfo.java:29) at com.jetbrains.php.lang.psi.elements.impl.PhpReferenceImpl.getType(PhpReferenceImpl.java:251) at com.jetbrains.php.lang.psi.resolve.types.PhpType.add(PhpType.java:550) at com.jetbrains.php.lang.psi.elements.impl.FunctionImpl.getType(FunctionImpl.java:501) at com.jetbrains.php.lang.psi.elements.impl.FunctionImpl$1.processReturnInstruction(FunctionImpl.java:333) at com.jetbrains.php.codeInsight.controlFlow.instructions.impl.PhpReturnInstructionImpl.process(PhpReturnInstructionImpl.java:21) at com.jetbrains.php.codeInsight.controlFlow.PhpControlFlowUtil.processSuccessors(PhpControlFlowUtil.java:239) at com.jetbrains.php.codeInsight.controlFlow.PhpControlFlowUtil.processSuccessors(PhpControlFlowUtil.java:219) at com.jetbrains.php.lang.psi.elements.impl.FunctionImpl.getInferredType(FunctionImpl.java:365) at com.jetbrains.php.lang.psi.elements.impl.FunctionImpl.getLocalType(FunctionImpl.java:231) at com.jetbrains.php.lang.psi.elements.impl.MethodImpl.getLocalType(MethodImpl.java:265) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeAnalyserVisitor.visitPhpMethod(PhpTypeAnalyserVisitor.java:806) at com.jetbrains.php.lang.psi.elements.impl.MethodImpl.accept(MethodImpl.java:94) at com.jetbrains.php.lang.psi.elements.impl.PhpPsiElementImpl.accept(PhpPsiElementImpl.java:73) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeAnalyserVisitor.getTypeFromAST(PhpTypeAnalyserVisitor.java:195) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.lambda$getTypeFromAST$1(PhpTypeInfo.java:80) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo$$Lambda$5625/0x0000000081f7a210.compute(Unknown Source) at com.intellij.openapi.util.RecursionGuard$$Lambda$2050/0x00000000813a3b28.compute(Unknown Source) at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:112) at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:42) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getTypeFromAST(PhpTypeInfo.java:78) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getTypeCached(PhpTypeInfo.java:61) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getType(PhpTypeInfo.java:43) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getType(PhpTypeInfo.java:29) at com.jetbrains.php.lang.psi.stubs.PhpMethodElementType.createStub(PhpMethodElementType.java:41) at com.jetbrains.php.lang.psi.stubs.PhpMethodElementType.createStub(PhpMethodElementType.java:26) at com.intellij.psi.stubs.DefaultStubBuilder$StubBuildingWalkingVisitor.createStub(DefaultStubBuilder.java:85) at com.intellij.psi.stubs.DefaultStubBuilder$StubBuildingWalkingVisitor.visitNode(DefaultStubBuilder.java:60) at com.intellij.psi.stubs.DefaultStubBuilder$StubBuildingWalkingVisitor.buildStubTree(DefaultStubBuilder.java:55) at com.intellij.psi.stubs.DefaultStubBuilder.buildStubTreeFor(DefaultStubBuilder.java:33) at com.intellij.psi.stubs.DefaultStubBuilder.buildStubTree(DefaultStubBuilder.java:22) at com.intellij.psi.stubs.StubTreeBuilder.lambda$buildStubTree$1(StubTreeBuilder.java:144) at com.intellij.psi.stubs.StubTreeBuilder$$Lambda$3079/0x00000000818d0000.compute(Unknown Source) at com.intellij.psi.stubs.StubTreeBuilder.handleStubBuilderException(StubTreeBuilder.java:99) at com.intellij.psi.stubs.StubTreeBuilder.lambda$buildStubTree$3(StubTreeBuilder.java:144) at com.intellij.psi.stubs.StubTreeBuilder$$Lambda$3076/0x00000000818ca560.compute(Unknown Source) at com.intellij.psi.impl.PsiManagerImpl.runInBatchFilesMode(PsiManagerImpl.java:457) at com.intellij.psi.stubs.StubTreeBuilder.buildStubTree(StubTreeBuilder.java:134) at com.intellij.psi.stubs.StubTreeBuilder.buildStubTree(StubTreeBuilder.java:92) at com.intellij.psi.stubs.PerFileElementTypeStubModificationTracker.preciseCheck(PerFileElementTypeStubModificationTracker.java:148) at com.intellij.psi.stubs.PerFileElementTypeStubModificationTracker.lambda$endUpdatesBatch$2(PerFileElementTypeStubModificationTracker.java:81) at com.intellij.psi.stubs.PerFileElementTypeStubModificationTracker$$Lambda$3058/0x00000000818c0530.run(Unknown Source) at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:60) at com.intellij.openapi.application.ReadAction$$Lambda$1864/0x0000000081202d78.compute(Unknown Source) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:891) at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:69) at com.intellij.openapi.application.ReadAction.run(ReadAction.java:59) at com.intellij.psi.stubs.PerFileElementTypeStubModificationTracker.endUpdatesBatch(PerFileElementTypeStubModificationTracker.java:76) at com.intellij.util.indexing.events.ChangedFilesCollector$4.endBatch(ChangedFilesCollector.java:246) at com.intellij.util.indexing.events.ChangedFilesCollector$5.lambda$endBatch$2(ChangedFilesCollector.java:283) at com.intellij.util.indexing.events.ChangedFilesCollector$5$$Lambda$3057/0x00000000818c02e8.run(Unknown Source) at com.intellij.util.ConcurrencyUtil.withLock(ConcurrencyUtil.java:243) at com.intellij.util.indexing.events.ChangedFilesCollector$5.endBatch(ChangedFilesCollector.java:282) at com.intellij.util.indexing.events.VfsEventsMerger.processChanges(VfsEventsMerger.java:109) at com.intellij.util.indexing.events.ChangedFilesCollector.processFilesInReadAction(ChangedFilesCollector.java:265) at com.intellij.util.indexing.events.ChangedFilesCollector.processFilesToUpdateInReadAction(ChangedFilesCollector.java:224) at com.intellij.util.indexing.events.ChangedFilesCollector.ensureUpToDate(ChangedFilesCollector.java:190) at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:799) at com.intellij.psi.stubs.StubIndexEx.getContainingIds(StubIndexEx.java:392) at com.intellij.psi.stubs.StubIndexEx.processElements(StubIndexEx.java:166) at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:103) at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:91) at com.jetbrains.php.PhpIndexImpl.getElements(PhpIndexImpl.java:639) at com.jetbrains.php.PhpIndexImpl.getByName(PhpIndexImpl.java:1076) at com.jetbrains.php.PhpIndexImpl.getByFQN(PhpIndexImpl.java:1053) at com.jetbrains.php.PhpIndexImpl.getByFqnCacheAware(PhpIndexImpl.java:1134) at com.jetbrains.php.PhpIndexImpl.getClassesByFQNInternal(PhpIndexImpl.java:1129) at com.jetbrains.php.PhpIndexImpl.getClassesByFQN(PhpIndexImpl.java:1118) at com.jetbrains.php.robo.run.RoboTasksToolWindowUpdateService.isRoboTaskClassExists(RoboTasksToolWindowUpdateService.java:90) at com.jetbrains.php.robo.run.RoboTasksToolWindowUpdateService$$Lambda$1933/0x00000000810adf18.call(Unknown Source) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$OTelMonitor.callWrapped(NonBlockingReadActionImpl.java:746) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$OTelMonitor$MonitoredComputation.call(NonBlockingReadActionImpl.java:778) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.insideReadAction(NonBlockingReadActionImpl.java:573) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$attemptComputation$3(NonBlockingReadActionImpl.java:537) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission$$Lambda$1859/0x00000000812053f0.run(Unknown Source) at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1089) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runInReadActionWithWriteActionPriority$0(ProgressIndicatorUtils.java:71) at com.intellij.openapi.progress.util.ProgressIndicatorUtils$$Lambda$1491/0x0000000080db9688.run(Unknown Source) at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:63) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:128) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runWithWriteActionPriority$1(ProgressIndicatorUtils.java:109) at com.intellij.openapi.progress.util.ProgressIndicatorUtils$$Lambda$1493/0x0000000080db9d40.compute(Unknown Source) at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$1(ProgressManager.java:70) at com.intellij.openapi.progress.ProgressManager$$Lambda$1494/0x0000000080db9fb0.run(Unknown Source) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186) at com.intellij.openapi.progress.impl.CoreProgressManager$$Lambda$1495/0x0000000080dba1f8.run(Unknown Source) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604) at com.intellij.openapi.progress.impl.CoreProgressManager$$Lambda$1496/0x0000000080dba440.compute(Unknown Source) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679) at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173) at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:70) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runWithWriteActionPriority(ProgressIndicatorUtils.java:106) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(ProgressIndicatorUtils.java:71) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.attemptComputation(NonBlockingReadActionImpl.java:537) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$transferToBgThread$1(NonBlockingReadActionImpl.java:444) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission$$Lambda$1855/0x0000000081204498.run(Unknown Source) at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:248) at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:28) at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:221) at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:213) at java.base@17.0.5/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base@17.0.5/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base@17.0.5/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702) at java.base@17.0.5/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699) at java.base@17.0.5/java.security.AccessController.executePrivileged(AccessController.java:776) at java.base@17.0.5/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base@17.0.5/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699) at java.base@17.0.5/java.lang.Thread.run(Thread.java:833)

wbars commented 1 year ago

@Haehnchen Hey, this freeze is happening pretty regularly on the upcoming PhpStorm 2023.1 EAP and there's no way of recovering from it, so it may be a serious issue in the IDE.

Main problem is that FilenameIndex#getFilesByName is invoked inside com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider3#getType, which is invoked during indexing. This is a violation of "no index access during indexing" contract, even DumbService.isDumb() check is not guaranteed to avoid the freeze.

Generally this index access call should be moved out of indexing phase to avoid freezes (namely out of PhpTypeProvider3#getType call). If .ide-toolbox.metadata.json is used only in child plugins, then one solution can be to hardcode it's content in plugin source code.

Is it possible to consider fixing this freeze for PhpStorm 2023.1 release? Should you need any help - please reach out!

ivanpajic commented 1 year ago

One more user reported this issue to JetBrains support.

slapoguzov commented 1 year ago

@Haehnchen Hello! I represent the PhpStorm team. We have received many reports of freezing related to this issue from our users. Since the problem still persists and often causes IDE completely hang, we are going to disable PhpToolboxTypeProvider in the next release (2023.1 RC2). It will be possible to enable the provider again by setting the registry key php.enable.php.toolbox.type.provider to true. Please, let us know as soon as the issue will be fixed in the plugin - then we’ll revert the fix on PhpStorm side. Do not hesitate to reach out to us if you require any assistance.

Haehnchen commented 1 year ago

i just pushed a new release to disable PhpToolboxTypeProvider for now, as 2023.1 coming soon. It needs to be migrated away from the deprecated typeprovider3 to typeprovider4