apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.66k stars 851 forks source link

ConcurrentModificationException: Caller uses obsolete token sequence which is no longer valid. #4192

Open vieiro opened 2 years ago

vieiro commented 2 years ago

Apache NetBeans version

Apache NetBeans latest daily build

What happened

I got the following exception in NB 14 (RC6)

java.util.ConcurrentModificationException: Caller uses obsolete token sequence which is no longer valid. Underlying token hierarchy has been modified by insertion or removal or a custom language embedding was created.TS.modCount=4602, tokenList.modCount()=4603, rootModCount=4603
Please report a bug against a module that calls lexer's code e.g. java, php etc. but not the lexer module itself.
    at org.netbeans.api.lexer.TokenSequence.checkValid(TokenSequence.java:784)
    at org.netbeans.api.lexer.TokenSequence.moveIndex(TokenSequence.java:568)
    at org.netbeans.modules.java.editor.base.semantic.TokenList.resetToIndex(TokenList.java:372)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.visitExpressionStatement(SemanticHighlighterBase.java:752)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.visitExpressionStatement(SemanticHighlighterBase.java:270)
    at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1592)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:69)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.scan(SemanticHighlighterBase.java:1006)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.scan(SemanticHighlighterBase.java:270)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
    at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:78)
    at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:272)
    at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1103)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:69)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.scan(SemanticHighlighterBase.java:1006)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.visitMethod(SemanticHighlighterBase.java:826)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.visitMethod(SemanticHighlighterBase.java:270)
    at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:953)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:69)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.scan(SemanticHighlighterBase.java:1006)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.scan(SemanticHighlighterBase.java:270)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
    at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:78)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.visitClass(SemanticHighlighterBase.java:934)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.visitClass(SemanticHighlighterBase.java:270)
    at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:860)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:69)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.scan(SemanticHighlighterBase.java:1006)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.scan(SemanticHighlighterBase.java:270)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
    at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:78)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.visitCompilationUnit(SemanticHighlighterBase.java:551)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.visitCompilationUnit(SemanticHighlighterBase.java:270)
    at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:614)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:69)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase$DetectorVisitor.scan(SemanticHighlighterBase.java:1006)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase.process(SemanticHighlighterBase.java:156)
    at org.netbeans.modules.java.editor.semantic.SemanticHighlighter.process(SemanticHighlighter.java:56)
    at org.netbeans.modules.java.editor.base.semantic.SemanticHighlighterBase.run(SemanticHighlighterBase.java:112)
    at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:561)
[catch] at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:786)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:279)
    at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
    at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

How to reproduce

Difficult to say :-(

Did this work correctly in an earlier version?

No

Operating System

Windows 10

JDK

OpenJDK Runtime Environment 11.0.15+9-LTS

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

Yes

Code of Conduct

Yes

solerman commented 2 years ago

Got hit by this, very same callstack in NB 13

eirikbakke commented 1 year ago

I've been getting this error and very similar call stack as well, probably 20 times in the past 4 months, on both NetBeans 17 and NetBeans 18. There's another report at https://github.com/apache/netbeans/issues/5631 .