izhangzhihao / intellij-rainbow-brackets

🌈Rainbow Brackets for IntelliJ based IDEs/Android Studio/HUAWEI DevEco Studio/Fleet
https://plugins.jetbrains.com/plugin/10080-rainbow-brackets
GNU General Public License v3.0
4.46k stars 214 forks source link

[Bug] IntelliJ throwing error for mismatch between PSI and index (even though they seem to be the same ???) #958

Closed solonovamax closed 3 years ago

solonovamax commented 3 years ago

Your programming language(s)

Kotlin

Description of The Bug

TL;DR sometimes when loading indexes for files, a UpToDateStubIndexMismatch exception is thrown.

Expected Behavior

The plugin should work normally and not throw errors lmao

Current Behavior

Currently, when pasting in some large blocks of code or when starting up IntelliJ & loading your projects (also maybe when loading a project with an already started IDEA instance. I just haven't run into it in that scenario. But basically, any instance where it loads a file & compares it to indexes.), there's a chance that you encounter a UpToDateStubIndexMismatch exception. Once this exception is thrown once, it will continue to be thrown every few 5-10 (ish?) seconds until your invalidate caches and restart the ide.

I've provided the stack trace here, but if you want other details such as the stubTree.txt, stubTreeFromIndex, inducde.txt, etc. then please see the attached tar.xz. (okay actually it's a tar.gz. It seems github doesn't like tar.xz.) I've put all of those files in there + all relevant files in my project. (I've also taken the liberty of including the specific class files that were generating the error, which are from !/.gradle/caches/6.8.1/generated-gradle-jars/gradle-api-6.8.1.jar!/org/gradle/configurationcache/problems/PropertyTrace*.class for convenience. But if you think that the files I've provided have somehow gotten modified, just grab the classes org.gradle.configurationcache.problems.PropertyTrace*.class from the gradle 6.8.1 jar.

Also, it seems that the dumped psi files from IntelliJ are actually identical???

[root@solo-main ERROR_FILES]# diff -s stubTree.txt stubTreeFromIndex.txt
Files stubTree.txt and stubTreeFromIndex.txt are identical

Yeah, I'm not sure either.....

If this is an issue with IntelliJ, I'll update & close this issue.

Here is a full stack trace (click to open) com.intellij.psi.stubs.UpToDateStubIndexMismatch: PSI and index do not match. Please report the problem to JetBrains with the files attached INDEXED VERSION IS THE CURRENT ONE file=KtFile: PropertyTrace.class, file.class=class org.jetbrains.kotlin.idea.decompiler.classFile.KtClsFile, file.lang=Language: kotlin, modStamp=1 AST INCONSISTENT, perhaps after incremental reparse; KtFile: PropertyTrace.class stub debugInfo=created in getStubTree(), with AST = false; with backReference latestIndexedStub=StubTree{myDebugInfo='created from index; with backReference', myRoot=PsiJetFileStubImpl[package=org.gradle.configurationcache.problems]}112252550 same size=true debugInfo=created from index; with backReference viewProvider=org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider{vFile=jar:///home/solonovamax/.gradle/caches/6.8.1/generated-gradle-jars/gradle-api-6.8.1.jar!/org/gradle/configurationcache/problems/PropertyTrace.class, vFileId=345664, content=VirtualFileContent{size=6409}, eventSystemEnabled=true} viewProvider stamp: 0; file stamp: 0; file modCount: 1611855568946; file length: 6409 doc saved: true; doc stamp: 0; doc size: 2937; committed: true indexing info: indexing timestamp = 1611855568946, binary = true, byte size = 6409, char size = -1 at com.intellij.psi.stubs.StubTreeLoader.handleUpToDateMismatch(StubTreeLoader.java:139) at com.intellij.psi.stubs.StubTreeLoader.lambda$stubTreeAndIndexDoNotMatch$0(StubTreeLoader.java:131) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$computeInNonCancelableSection$3(CoreProgressManager.java:239) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:660) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:612) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63) at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:220) at com.intellij.openapi.progress.impl.CoreProgressManager.computeInNonCancelableSection(CoreProgressManager.java:237) at com.intellij.psi.stubs.StubTreeLoader.stubTreeAndIndexDoNotMatch(StubTreeLoader.java:60) at com.intellij.psi.impl.source.FileTrees.reconcilePsi(FileTrees.java:202) at com.intellij.psi.impl.source.FileTrees.withAst(FileTrees.java:150) at com.intellij.psi.impl.source.PsiFileImpl.loadTreeElement(PsiFileImpl.java:210) at com.intellij.psi.impl.source.PsiFileImpl.calcTreeElement(PsiFileImpl.java:730) at com.intellij.psi.impl.source.PsiFileImpl.getNode(PsiFileImpl.java:933) at com.intellij.psi.impl.source.PsiFileImpl.getNode(PsiFileImpl.java:48) at com.intellij.psi.AbstractFileViewProvider.findElementAt(AbstractFileViewProvider.java:244) at com.intellij.psi.AbstractFileViewProvider.findElementAt(AbstractFileViewProvider.java:215) at com.intellij.psi.util.PsiTreeUtil.findElementOfClassAtRange(PsiTreeUtil.java:1039) at org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile.getDeclaration(KtDecompiledFile.kt:38) at org.jetbrains.kotlin.idea.caches.lightClasses.LightMemberOriginForCompiledElementKt.findDeclarationInCompiledFile(LightMemberOriginForCompiledElement.kt:129) at org.jetbrains.kotlin.idea.caches.lightClasses.LightMemberOriginForCompiledMethod$originalElement$2.invoke(LightMemberOriginForCompiledElement.kt:100) at org.jetbrains.kotlin.idea.caches.lightClasses.LightMemberOriginForCompiledMethod$originalElement$2.invoke(LightMemberOriginForCompiledElement.kt:81) at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107) at org.jetbrains.kotlin.idea.caches.lightClasses.LightMemberOriginForCompiledMethod.getOriginalElement(LightMemberOriginForCompiledElement.kt) at org.jetbrains.kotlin.idea.caches.lightClasses.decompiledDeclarations.KtLightMethodForDecompiledDeclaration.getKotlinOrigin(KtLightMethodForDecompiledDeclaration.kt:28) at org.jetbrains.kotlin.idea.caches.lightClasses.decompiledDeclarations.KtLightMethodForDecompiledDeclaration.getKotlinOrigin(KtLightMethodForDecompiledDeclaration.kt:22) at org.jetbrains.kotlin.asJava.LightClassUtil$getPsiMethodWrappers$2.invoke(LightClassUtil.kt:143) at org.jetbrains.kotlin.asJava.LightClassUtil$getPsiMethodWrappers$2.invoke(LightClassUtil.kt:36) at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:171) at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:194) at org.jetbrains.kotlin.asJava.LightClassUtil.extractPropertyAccessors(LightClassUtil.kt:324) at org.jetbrains.kotlin.asJava.LightClassUtil.getLightClassPropertyMethods(LightClassUtil.kt:90) at org.jetbrains.kotlin.asJava.LightClassUtilKt.getAccessorLightMethods(LightClassUtil.kt:290) at org.jetbrains.kotlin.idea.caches.KotlinShortNamesCache$processMethodsWithName$allProcessed$1.process(KotlinShortNamesCache.kt:209) at org.jetbrains.kotlin.idea.caches.KotlinShortNamesCache$processMethodsWithName$allProcessed$1.process(KotlinShortNamesCache.kt:40) at com.intellij.psi.stubs.StubProcessingHelperBase.processStubsInFile(StubProcessingHelperBase.java:73) at com.intellij.psi.stubs.StubIndexImpl.lambda$processElements$2(StubIndexImpl.java:283) at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:338) at org.jetbrains.kotlin.idea.caches.KotlinShortNamesCache.processMethodsWithName(KotlinShortNamesCache.kt:201) at com.intellij.psi.impl.CompositeShortNamesCache.processMethodsWithName(CompositeShortNamesCache.java:182) at com.intellij.psi.impl.CompositeShortNamesCache.processMethodsWithName(CompositeShortNamesCache.java:173) at org.jetbrains.kotlin.idea.core.KotlinIndicesHelper.getMethodsByNameUnfiltered(KotlinIndicesHelper.kt:350) at org.jetbrains.kotlin.idea.core.KotlinIndicesHelper.getJavaCallables(KotlinIndicesHelper.kt:336) at org.jetbrains.kotlin.idea.core.KotlinIndicesHelper.processJvmCallablesByName(KotlinIndicesHelper.kt:278) at org.jetbrains.kotlin.idea.quickfix.AbstractImportFix.collectMemberCandidates(AbstractImportFix.kt:326) at org.jetbrains.kotlin.idea.quickfix.AbstractImportFix.fillCandidates(AbstractImportFix.kt:389) at org.jetbrains.kotlin.idea.quickfix.ImportFixBase.collectSuggestionsForName(AbstractImportFix.kt:167) at org.jetbrains.kotlin.idea.quickfix.ImportFixBase.collectSuggestions(AbstractImportFix.kt:135) at org.jetbrains.kotlin.idea.quickfix.ImportFixBase.computeSuggestions(AbstractImportFix.kt:80) at org.jetbrains.kotlin.idea.quickfix.ImportFixBase$Factory.createAction(AbstractImportFix.kt:221) at org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory.doCreateActions(KotlinSingleIntentionActionFactory.kt:25) at org.jetbrains.kotlin.idea.quickfix.KotlinIntentionActionsFactory.createActions(KotlinIntentionActionsFactory.kt:42) at org.jetbrains.kotlin.idea.quickfix.KotlinIntentionActionsFactory.createActionsForAllProblems(KotlinIntentionActionsFactory.kt:24) at org.jetbrains.kotlin.idea.highlighter.KotlinPsiCheckerKt.createQuickFixes(KotlinPsiChecker.kt:104) at org.jetbrains.kotlin.idea.highlighter.KotlinPsiCheckerKt.access$createQuickFixes(KotlinPsiChecker.kt:1) at org.jetbrains.kotlin.idea.highlighter.ElementAnnotator.setUpAnnotations(KotlinPsiChecker.kt:263) at org.jetbrains.kotlin.idea.highlighter.ElementAnnotator.registerDiagnosticAnnotations(KotlinPsiChecker.kt:258) at org.jetbrains.kotlin.idea.highlighter.ElementAnnotator.registerDiagnosticsAnnotations(KotlinPsiChecker.kt:182) at org.jetbrains.kotlin.idea.highlighter.KotlinPsiChecker.annotateElement(KotlinPsiChecker.kt:75) at org.jetbrains.kotlin.idea.highlighter.KotlinPsiChecker.annotateElement(KotlinPsiChecker.kt:57) at org.jetbrains.kotlin.idea.highlighter.AbstractKotlinPsiChecker.annotate(AbstractKotlinPsiChecker.kt:20) at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.runAnnotators(DefaultHighlightVisitor.java:136) at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.visit(DefaultHighlightVisitor.java:116) at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.runVisitors(GeneralHighlightingPass.java:335) at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$collectHighlights$5(GeneralHighlightingPass.java:274) at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:294) at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$6(GeneralHighlightingPass.java:297) at com.github.izhangzhihao.rainbow.brackets.visitor.RainbowHighlightVisitor.analyze(RainbowHighlightVisitor.kt:68) at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:297) at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$6(GeneralHighlightingPass.java:297) at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:96) at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:297) at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:265) at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:211) at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:84) at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:56) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:400) at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1114) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:393) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:660) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:612) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:392) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:368) at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:167) at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:181) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:366) at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:188) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) Caused by: java.lang.AssertionError: Stub count doesn't match stubbed node length at com.intellij.psi.impl.source.FileTrees.lambda$reconcilePsi$5(FileTrees.java:190) at com.intellij.psi.impl.DebugUtil.performPsiModification(DebugUtil.java:577) at com.intellij.psi.impl.source.FileTrees.reconcilePsi(FileTrees.java:183) ... 83 more

Possible Solution

My current solution is to completely invalidate all the caches for the IDE and restart. Not the best solution, but it mostly works.

If possible, it would be nice if you could just invalidate the caches for the specific file in which this occurs, and then force IntelliJ to reload them. That should™ fix the issues with it. (I'm assuming that you have the capability to do that in the API that IntelliJ provides you. If not, then well.... it'll probably be a much harder problem to solve.)

Code snippet for reproducing (for bugs)

Even though I know this error is occurring in a class outside of my project, I've still dumped my full project to a tar.xz (okay actually it's a tar.gz. It seems github doesn't like tar.xz.), in case there's something in my project that is triggering this. (To maybe make it easier to reproduce.) I've attached a tar.xz of all of the (non generated) files in my project, and all of the relevant error files. (I'm going to eventually make this gradle plugin FOSS when I get it to actually work, so I don't care about sharing the files.)

The error files that IntelliJ has generated are in ERROR_FILLES/*.txt. In addition to the error files that were generated by IDEA, I've also taken the liberty of including the specific classes that seemed to be causing the error, which are PropertyTrace*.class. These are copied straight from the jar file at the location ~/.gradle/caches/6.8.1/generated-gradle-jars/gradle-api-6.8.1.jar!/org/gradle/configurationcache/problems/PropertyTrace*.class. (If you have this specific jar, you can decompile that in case you suspect the class files somehow got modified.)

Your Environment

Name Value
Operating System Arch Linux x86_64 5.10.11-arch1-1
IDE Version IntelliJ IDEA 2021.1 EAP (Ultimate Edition)
IDE Build Build #IU-211.4961.33, built on January 27, 2021
Java Runtime Version 11.0.9.1+11-b1257.1 amd64
Non-Bundled Plugins
Plugins (Click to expand)Batch Scripts Support (1.0.12)
CMD Support (1.0.5)
com.floobits.unique.plugin.id (1.7.3)
com.fwdekker.randomness (2.7.0)
com.github.b3er.idea.plugins.arc.browser (0.23)
com.github.camork.fileExpander (1.6)
com.intellij.ideolog (203.0.26.0)
com.intellij.plugins.kdekeymap (203.5981.152)
com.ultrahob.zerolength.plugin (0.93)
com.wakatime.intellij.plugin (11.0.1)
net.codestats.plugin.atom.intellij (1.0.9)
net.seesharpsoft.intellij.plugins.csv (2.14.3)
one.util.ideaplugin.screenshoter (1.5)
org.antlr.intellij.plugin (1.16)
com.almightyalpaca.intellij.plugins.discord (1.6.1)
mobi.hsz.idea.gitignore (4.0.4-eap)
Builder Generator (1.1.8)
CheckStyle-IDEA (5.46.0)
EclipseCodeFormatter (20.7.201.6668.0-Eclipse_2020-06-JavaOnly)
String Manipulation (8.10.191.000.0)
com.godwin.json.parser (1.4.2)
org.github.otanikotani.checks-plugin (1.1.9)
org.sonarlint.idea (4.13.0.24781)
com.hotswap.agent.plugin (1.3.0)
izhangzhihao.rainbow.brackets (6.15)
com.intellij.lang.jsgraphql (2.7.1)
com.github.shiraji.yaemoji (1.0.7)
nl.rubensten.texifyidea (0.7.3)
Kotlin 211-1.4.21-release-IJ4961.6
Plugin Version Latest (6.15)
Full Dump of IDE Environment IntelliJ IDEA 2021.1 EAP (Ultimate Edition)
Build #IU-211.4961.33, built on January 27, 2021
IntelliJ IDEA EAP User
Expiration date: February 26, 2021
Runtime version: 11.0.9.1+11-b1257.1 amd64
VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
Linux 5.10.11-arch1-1
GC: G1 Young Generation, G1 Old Generation
Memory: 3072M
Cores: 12
Registry: ide.balloon.shadow.size=0
Non-Bundled Plugins: Batch Scripts Support (1.0.12), CMD Support (1.0.5), com.floobits.unique.plugin.id (1.7.3), com.fwdekker.randomness (2.7.0), com.github.b3er.idea.plugins.arc.browser (0.23), com.github.camork.fileExpander (1.6), com.intellij.ideolog (203.0.26.0), com.intellij.plugins.kdekeymap (203.5981.152), com.ultrahob.zerolength.plugin (0.93), com.wakatime.intellij.plugin (11.0.1), net.codestats.plugin.atom.intellij (1.0.9), net.seesharpsoft.intellij.plugins.csv (2.14.3), one.util.ideaplugin.screenshoter (1.5), org.antlr.intellij.plugin (1.16), com.almightyalpaca.intellij.plugins.discord (1.6.1), mobi.hsz.idea.gitignore (4.0.4-eap), Builder Generator (1.1.8), CheckStyle-IDEA (5.46.0), EclipseCodeFormatter (20.7.201.6668.0-Eclipse_2020-06-JavaOnly), String Manipulation (8.10.191.000.0), com.godwin.json.parser (1.4.2), org.github.otanikotani.checks-plugin (1.1.9), org.sonarlint.idea (4.13.0.24781), com.hotswap.agent.plugin (1.3.0), izhangzhihao.rainbow.brackets (6.15), com.intellij.lang.jsgraphql (2.7.1), com.github.shiraji.yaemoji (1.0.7), nl.rubensten.texifyidea (0.7.3)
Kotlin: 211-1.4.21-release-IJ4961.6
Current Desktop: KDE

tarball of the sources for my project + errors

github-actions[bot] commented 3 years ago

This auto generated issue has been automatically marked as wontfix because it's nothing wrong here. If you think there are something really wrong, please reply this issue. Thanks for your cooperation.

solonovamax commented 3 years ago

dawg, wHAT????

How was this marked as an auto generated issue??? lmao

solonovamax commented 3 years ago

@izhangzhihao sorry for the @ mention, but this issue got closed for no reason lmao

ya think you could reopen it?

izhangzhihao commented 3 years ago

Sorry, your issue triggered GitHub actions, which mark this issue closed.

solonovamax commented 3 years ago

it's all good

izhangzhihao commented 3 years ago

Similar issue: https://github.com/mplushnikov/lombok-intellij-plugin/issues/364

But to be honest, I have no idea what's wrong and how to fix it, I will submit it to https://youtrack.jetbrains.com/issues

izhangzhihao commented 3 years ago

Please follow: https://youtrack.jetbrains.com/issue/IDEA-261514

izhangzhihao commented 3 years ago

Since this plugin has nothing to do with this issue, I will close this issue, for further info please follow: https://youtrack.jetbrains.com/issue/IDEA-261514