netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

NB Occasionally Will Throw NPE When Saving Files

Open mwarble opened this issue 3 years ago • 3 comments

Apache NetBeans version

Apache NetBeans 14

What happened

Occasionally when saving modified files, NB will hang indefinitely. Log shows NullPointerException:

----- Original exception --------------------------------------------- java.lang.IllegalStateException: java.lang.NullPointerException at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:383) at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:770) at org.netbeans.modules.java.source.parsing.CompilationInfoImpl.toPhase(CompilationInfoImpl.java:426) at org.netbeans.api.java.source.CompilationController.toPhase(CompilationController.java:88) at org.netbeans.modules.java.completion.JavaCompletionTask.insideMemberSelect(JavaCompletionTask.java:1634) at org.netbeans.modules.java.completion.JavaCompletionTask.resolve(JavaCompletionTask.java:354) at org.netbeans.modules.java.completion.BaseTask.run(BaseTask.java:94) at org.netbeans.modules.java.completion.JavaCompletionTask.run(JavaCompletionTask.java:63) at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:586) at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:132) at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:116) at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:181) at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:178) at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153) at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:335) at org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:118) at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:67) at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:178) at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:83) at org.netbeans.modules.editor.java.JavaCompletionProvider$JavaCompletionQuery.query(JavaCompletionProvider.java:193) at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:198) 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) Caused by: java.lang.NullPointerException at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1458) at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1797) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444) at com.sun.tools.javac.tree.TreeScanner.visitExec(TreeScanner.java:219) at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1584) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57) at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:1207) at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1091) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444) at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitTry(Flow.java:1328) at com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:1446) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57) at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:1207) at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1091) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444) at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitMethodDef(Flow.java:1173) at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:921) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444) at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitClassDef(Flow.java:1136) at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:819) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444) at com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1551) at com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1541) at com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:222) at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1377) at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1341) at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:404) at com.sun.tools.javac.api.JavacTaskImpl.lambda$analyze$1(JavacTaskImpl.java:379) at com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152) at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:379) ... 24 more

How to reproduce

Not sure how to reproduce the problem.

Did this work correctly in an earlier version?

Apache NetBeans 13

Operating System

Windows 10

JDK

Eclipse Foundation JDK-11.0.12.7-hotspot

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

It's random. Sometimes happens several times a day. May go several days without any issues.

Are you willing to submit a pull request?

No

Code of Conduct

Yes

mwarble avatar Jul 07 '22 16:07 mwarble

can you run NB on JDK 17 so that we get a more precise NPE showing what exactly is null?

mbien avatar Jul 08 '22 01:07 mbien

I can, but I'm not sure how long it will take to reproduce the problem. I'll post stack trace once it happens again.

mwarble avatar Jul 08 '22 12:07 mwarble

Here's an updated stack trace with JDK17.

----- Original exception ---------------------------------------------

java.lang.IllegalStateException: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.getThrownTypes()" because "tree.meth.type" is null
	at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:383)
	at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:770)
	at org.netbeans.modules.java.source.parsing.CompilationInfoImpl.toPhase(CompilationInfoImpl.java:426)
	at org.netbeans.api.java.source.CompilationController.toPhase(CompilationController.java:88)
	at org.netbeans.modules.java.completion.JavaCompletionTask.insideMemberSelect(JavaCompletionTask.java:1634)
	at org.netbeans.modules.java.completion.JavaCompletionTask.resolve(JavaCompletionTask.java:354)
	at org.netbeans.modules.java.completion.BaseTask.run(BaseTask.java:94)
	at org.netbeans.modules.java.completion.JavaCompletionTask.run(JavaCompletionTask.java:63)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:586)
	at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:132)
	at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:116)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:181)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:178)
	at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153)
	at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:335)
	at org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:118)
	at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:67)
	at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:178)
	at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:83)
	at org.netbeans.modules.editor.java.JavaCompletionProvider$JavaCompletionQuery.query(JavaCompletionProvider.java:193)
	at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:198)
	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)
Caused by: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.getThrownTypes()" because "tree.meth.type" is null
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1458)
	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1797)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
	at com.sun.tools.javac.tree.TreeScanner.visitExec(TreeScanner.java:219)
	at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1584)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:1207)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1091)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitTry(Flow.java:1328)
	at com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:1446)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:1207)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1091)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitMethodDef(Flow.java:1173)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:921)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitClassDef(Flow.java:1136)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:819)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1551)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1541)
	at com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:222)
	at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1377)
	at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1341)
	at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:404)
	at com.sun.tools.javac.api.JavacTaskImpl.lambda$analyze$1(JavacTaskImpl.java:379)
	at com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
	at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:379)
	... 24 more

mwarble avatar Jul 23 '22 19:07 mwarble