Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 340064

Summary: NPE using CaseBreak checker
Product: [Tools] CDT Reporter: Marc-AndrĂ© Laperle <malaperle>
Component: cdt-codanAssignee: Project Inbox <cdt-core-inbox>
Status: RESOLVED FIXED QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug
Version: 8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Here is the log. none

Description Marc-André Laperle CLA 2011-03-15 13:26:57 EDT
Using 8.0.0.201103130630

java.lang.NullPointerException
at org.eclipse.cdt.codan.core.cxx.model.CxxModelsCache.getAst(CxxModelsCache.java:80)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker$SwitchVisitor.<init>(CaseBreakChecker.java:125)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker$SwitchFindingVisitor.visit(CaseBreakChecker.java:93)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSwitchStatement.accept(CPPASTSwitchStatement.java:97)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement.accept(CPPASTCompoundStatement.java:79)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition.accept(CPPASTFunctionDefinition.java:187)
at org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit.accept(ASTTranslationUnit.java:271)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker.processAst(CaseBreakChecker.java:268)
Comment 1 Andrew Gvozdev CLA 2011-03-22 10:59:44 EDT
I am having another kind of exception in the checker. Let me know if you want me to isolate which code causes that. I'd rather to avoid that as the code base is large so it would take quite an effort.

java.lang.IllegalArgumentException: Not cached
at org.eclipse.cdt.codan.core.cxx.model.CxxModelsCache.getCommentedNodeMap(CxxModelsCache.java:99)
at org.eclipse.cdt.codan.core.cxx.CxxAstUtils.getLeadingComment(CxxAstUtils.java:404)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker$SwitchVisitor.getLeadingComment(CaseBreakChecker.java:218)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker$SwitchVisitor.visit(CaseBreakChecker.java:195)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTCaseStatement.accept(CASTCaseStatement.java:65)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTCompoundStatement.accept(CASTCompoundStatement.java:77)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTSwitchStatement.accept(CASTSwitchStatement.java:90)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker$SwitchFindingVisitor.visit(CaseBreakChecker.java:94)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTSwitchStatement.accept(CASTSwitchStatement.java:83)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTCompoundStatement.accept(CASTCompoundStatement.java:77)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTFunctionDefinition.accept(CASTFunctionDefinition.java:128)
at org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit.accept(ASTTranslationUnit.java:271)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker.processAst(CaseBreakChecker.java:268)
at org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker.processModel(AbstractIndexAstChecker.java:124)
at org.eclipse.cdt.codan.internal.core.CodanBuilder.processResource(CodanBuilder.java:141)
at org.eclipse.cdt.codan.internal.core.CodanBuilder.runInEditor(CodanBuilder.java:206)
at org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanReconciler.reconciledAst(CxxCodanReconciler.java:38)
at org.eclipse.cdt.codan.internal.ui.cxx.CodanCReconciler.reconciled(CodanCReconciler.java:92)
at org.eclipse.cdt.internal.ui.editor.CEditor.reconciled(CEditor.java:3065)
at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:105)
at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:71)
at org.eclipse.cdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:84)
at org.eclipse.cdt.internal.ui.text.CCompositeReconcilingStrategy.reconcile(CCompositeReconcilingStrategy.java:90)
at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
at org.eclipse.cdt.internal.ui.text.CReconciler.process(CReconciler.java:408)
at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Comment 2 Elena Laskavaia CLA 2011-04-07 23:47:05 EDT
Is this still happening?
Comment 3 Andrew Gvozdev CLA 2011-04-08 09:22:50 EDT
I got about 2 dozen of Codan exceptions in yesterdays log, all slightly different. Here is a fresh sample:
java.lang.NullPointerException
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker$SwitchVisitor.getLeadingComment(CaseBreakChecker.java:211)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker$SwitchVisitor.visit(CaseBreakChecker.java:188)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTCaseStatement.accept(CASTCaseStatement.java:65)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTCompoundStatement.accept(CASTCompoundStatement.java:77)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTSwitchStatement.accept(CASTSwitchStatement.java:90)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker$SwitchFindingVisitor.visit(CaseBreakChecker.java:92)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTSwitchStatement.accept(CASTSwitchStatement.java:83)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTCompoundStatement.accept(CASTCompoundStatement.java:77)
at org.eclipse.cdt.internal.core.dom.parser.c.CASTFunctionDefinition.accept(CASTFunctionDefinition.java:128)
at org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit.accept(ASTTranslationUnit.java:276)
at org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker.processAst(CaseBreakChecker.java:262)
at org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker.processModel(AbstractIndexAstChecker.java:142)
at org.eclipse.cdt.codan.internal.core.CodanBuilder.processResource(CodanBuilder.java:142)
at org.eclipse.cdt.codan.internal.core.CodanBuilder.runInEditor(CodanBuilder.java:207)
at org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanReconciler.reconciledAst(CxxCodanReconciler.java:38)
at org.eclipse.cdt.codan.internal.ui.cxx.CodanCReconciler.reconciled(CodanCReconciler.java:81)
at org.eclipse.cdt.internal.ui.editor.CEditor.reconciled(CEditor.java:3065)
at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:105)
at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:71)
at org.eclipse.cdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:84)
at org.eclipse.cdt.internal.ui.text.CCompositeReconcilingStrategy.reconcile(CCompositeReconcilingStrategy.java:90)
at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
at org.eclipse.cdt.internal.ui.text.CReconciler.process(CReconciler.java:408)
at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Comment 4 Andrew Gvozdev CLA 2011-04-08 09:28:19 EDT
Created attachment 192828 [details]
Here is the log.
Comment 5 Andrew Gvozdev CLA 2011-04-11 16:00:46 EDT
This one is not so easy to pinpoint. I was watching myself and noted that the exceptions appeared after using Search and Replace operation (I used File Search). An attempt to run code analysis on the affected files or on the whole project did not produce the exceptions (produced regular codan warnings about missing break though).
Comment 6 Elena Laskavaia CLA 2011-04-24 21:00:05 EDT
Sergey did a refactoring which could have take care of it. Re-open if you see it again (after update to latest head code of cause)
Comment 7 Andrew Gvozdev CLA 2011-04-24 21:55:52 EDT
There were new entries in my log every day before Sergey did the refactoring. I haven't seen them since.