[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CastCheckEliminator
Ondrej LHOTAK wrote:
> > > > Is it a well-known fact that CastCheckEliminator is broken [1]?
> > > > Just curious if so, and whether there are any plans to fix it.
> > >
> > > It was not well-known that it's broken until I read your bug report this
> > > morning. I'm working on fixing it...
Thanks again for fixing that bug..
Now there appears to be another (I think much simpler) bug [1] in
CastCheckEliminator. It looks to me like it doesn' properly handle
the case where thing being cast is the null constant. E.g., I'm
getting this exception when analyzing a certain class (fyi it happens
to be polyglot/ext/jl/ast/AbstractDelFactory_c):
java.lang.ClassCastException: soot.jimple.NullConstant
at soot.jimple.toolkits.pointer.CastCheckEliminator.flowThrough(CastCheckEliminator.java:135)
at soot.toolkits.scalar.ForwardBranchedFlowAnalysis.doAnalysis(ForwardBranchedFlowAnalysis.java:240)
at soot.jimple.toolkits.pointer.CastCheckEliminator.<init>(CastCheckEliminator.java:38)
at soot.jimple.toolkits.pointer.CastCheckEliminatorDumper.internalTransform(CastCheckEliminatorDumper.java:35
)
at soot.BodyTransformer.transform(BodyTransformer.java:51)
The relevant code is:
132 CastExpr cast = (CastExpr) rhs;
133 Type castType = cast.getCastType();
134 if( castType instanceof RefType ) {
135 out.localCopy( l, (Local) cast.getOp() );
135 out.localMustBeSubtypeOf( l, (RefType) castType );
137 out.localMustBeSubtypeOf( (Local) cast.getOp(),
138 (RefType) castType );
139 }
It's assuming cast.getOp() is a local, but it's a NullConstant.
Similar code appears on line 53:
52 if( t instanceof RefType ) {
52 Local l = (Local) cast.getOp();
54 LocalTypeSet set = (LocalTypeSet) unitToBeforeFlow.get(s);
55 s.addTag( new CastCheckTag( set.get( set.indexOf(
56 l, (RefType) t ) ) ) );
57 }
-Archie
[1] http://www.sable.mcgill.ca/sootbugs/incoming?id=95
__________________________________________________________________________
Archie Cobbs * CTO, Awarix * http://www.awarix.com