roterdam / crystalsaf

Automatically exported from code.google.com/p/crystalsaf
0 stars 0 forks source link

NPE in EclipseCFG for uncaught exceptions #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Running the Eclipse CFG on the following code produces a NPE in
endVisit(ThrowStatement) (trace below). Looks like the non-existing catch
node for the thrown exception is dereferenced without check.

    ResultSetIterator(ControlBeanContext context, Method method, ResultSet
rs, Calendar cal) {
        _rs = rs;

        JdbcControl.SQL methodSQL = (JdbcControl.SQL)
context.getMethodPropertySet(method, JdbcControl.SQL.class);
        _returnClass = methodSQL.iteratorElementType();

        if (_returnClass == null) {
            throw new ControlException("Invalid return class declared for
Iterator:" + _returnClass.getName());
        }

        _rowMapper = RowMapperFactory.getRowMapper(rs, _returnClass, cal);
    }

Relevant part of trace:

Jul 10, 2008 10:18:10 AM edu.cmu.cs.crystal.Crystal runAnalysesOnSingleUnit
SEVERE: Exception during analysis [ FractionalAnalysis ]
java.lang.NullPointerException
    at edu.cmu.cs.crystal.cfg.eclipse.EclipseCFG.endVisit(EclipseCFG.java:866)
    at org.eclipse.jdt.core.dom.ThrowStatement.accept0(ThrowStatement.java:142)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
    at org.eclipse.jdt.core.dom.Block.accept0(Block.java:135)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2523)
    at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:189)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at edu.cmu.cs.crystal.cfg.eclipse.EclipseCFG.visit(EclipseCFG.java:663)
    at
org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:486)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at
edu.cmu.cs.crystal.cfg.eclipse.EclipseCFG.createGraph(EclipseCFG.java:179)
    at edu.cmu.cs.crystal.cfg.eclipse.EclipseCFG.<init>(EclipseCFG.java:167)
    at
edu.cmu.cs.crystal.cfg.eclipse.EclipseNodeFirstCFG.<init>(EclipseNodeFirstCFG.ja
va:43)
    at
edu.cmu.cs.crystal.flow.experimental.AbstractWorklist.getControlFlowGraph(Abstra
ctWorklist.java:71)
    at
edu.cmu.cs.crystal.flow.experimental.WorklistTemplate.performAnalysis(WorklistTe
mplate.java:80)
    at
edu.cmu.cs.crystal.flow.MotherFlowAnalysis.performAnalysis(MotherFlowAnalysis.ja
va:387)
    at
edu.cmu.cs.crystal.flow.MotherFlowAnalysis.switchToMethod(MotherFlowAnalysis.jav
a:381)
    at
edu.cmu.cs.crystal.flow.MotherFlowAnalysis.performAnalysisOnSurroundingMethodIfN
eeded(MotherFlowAnalysis.java:369)
    at
edu.cmu.cs.crystal.flow.MotherFlowAnalysis.getStartResults(MotherFlowAnalysis.ja
va:168)
    at
edu.cmu.cs.plural.alias.AliasAwareTupleLE.getStartLocations(AliasAwareTupleLE.ja
va:561)
    at
edu.cmu.cs.plural.track.PluralTupleLatticeElement.storeInitialAliasingInfo(Plura
lTupleLatticeElement.java:237)
    at
edu.cmu.cs.plural.track.FractionalTransfer.getLattice(FractionalTransfer.java:15
4)
    at
edu.cmu.cs.crystal.tac.TACFlowAnalysis$AbstractTACAnalysisDriver.getLattice(TACF
lowAnalysis.java:222)
    at
edu.cmu.cs.crystal.flow.experimental.BranchSensitiveWorklist.getLattice(BranchSe
nsitiveWorklist.java:81)
    at
edu.cmu.cs.crystal.flow.experimental.WorklistTemplate.performAnalysis(WorklistTe
mplate.java:78)
    at
edu.cmu.cs.crystal.flow.MotherFlowAnalysis.performAnalysis(MotherFlowAnalysis.ja
va:387)
    at
edu.cmu.cs.crystal.flow.MotherFlowAnalysis.switchToMethod(MotherFlowAnalysis.jav
a:381)
    at
edu.cmu.cs.crystal.flow.MotherFlowAnalysis.performAnalysisOnSurroundingMethodIfN
eeded(MotherFlowAnalysis.java:369)
    at
edu.cmu.cs.crystal.flow.MotherFlowAnalysis.getResultsBefore(MotherFlowAnalysis.j
ava:107)
    at
edu.cmu.cs.plural.track.FractionalAnalysis$FractionalChecker.endVisit(Fractional
Analysis.java:259)
    at
org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:246)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2523)
    at org.eclipse.jdt.core.dom.CastExpression.accept0(CastExpression.java:162)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2523)
    at
org.eclipse.jdt.core.dom.VariableDeclarationFragment.accept0(VariableDeclaration
Fragment.java:224)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
    at
org.eclipse.jdt.core.dom.VariableDeclarationStatement.accept0(VariableDeclaratio
nStatement.java:272)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
    at org.eclipse.jdt.core.dom.Block.accept0(Block.java:135)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2523)
    at
org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:501)
    at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
    at
edu.cmu.cs.plural.track.FractionalAnalysis.analyzeMethod(FractionalAnalysis.java
:108)
    at
edu.cmu.cs.crystal.AbstractCrystalMethodAnalysis.runAnalysis(AbstractCrystalMeth
odAnalysis.java:69)
    at edu.cmu.cs.crystal.Crystal.runAnalysesOnSingleUnit(Crystal.java:402)
    at edu.cmu.cs.crystal.Crystal.runAnalysesOnMultiUnit(Crystal.java:374)
    at edu.cmu.cs.crystal.Crystal.runAnalyses(Crystal.java:264)
    at
edu.cmu.cs.crystal.internal.CrystalFileAction.run(CrystalFileAction.java:75)

Original issue reported on code.google.com by ciera.christopher on 10 Jul 2008 at 2:32

GoogleCodeExporter commented 9 years ago
Is that a runtime exception or something? I had made the assumption that there 
will
always be a throws declaration.

Maybe I'll make a separate end point for runtime exceptions. Actually, I can 
connect
the asserts up to that too, except they won't be labeled as an exception edge. 
Would
that work?

Original comment by ciera.christopher on 10 Jul 2008 at 2:40

GoogleCodeExporter commented 9 years ago
New test cases are in.

Original comment by ciera.christopher on 10 Jul 2008 at 5:55

GoogleCodeExporter commented 9 years ago
New test cases are in.

Original comment by ciera.christopher on 10 Jul 2008 at 5:55

GoogleCodeExporter commented 9 years ago

Original comment by ciera.christopher on 10 Jul 2008 at 5:56

GoogleCodeExporter commented 9 years ago
Looks like this works for the code now that caused the problem for me.  Yes, the
thrown exception was a runtime exception.  Does this "runtime exception" exit 
exist
now?  I like the idea of hooking up asserts to this exit as well.  As discussed
before, we could even label those edges with Throwable or Error.  

Original comment by kevin.bi...@gmail.com on 13 Jul 2008 at 7:05

GoogleCodeExporter commented 9 years ago
Yeah, I committed the change. I hooked up asserts to this with the Throwable 
label.
There's a public getter to this exceptional exit, separate from the declared
exceptions and the uber-return.

Original comment by ciera.christopher on 14 Jul 2008 at 12:27