[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Soot typing failure



The typing system fails on the following code.

public class test
{
    public void main() {
        if (null instanceof String)
            System.out.println("is String");
        else
            System.out.println("is not String");
    }
}

The code in ConstraintChecker generally assumes that expressions are of locals, however, in the above case, that is
obviously not true.


--- ptII/vendors/soot/2.0.1/soot/src/soot/jimple/toolkits/typing/ConstraintChecker.java 2003-07-25 15:02:30.554116000 -0700
+++ ptII/soot/jimple/toolkits/typing/ConstraintChecker.java 2003-11-15 22:19
:47.000000000 -0800@@ -591,7 +607,7 @@
{
InstanceOfExpr ioe = (InstanceOfExpr) r;
TypeNode type = hierarchy.typeNode(ioe.getCheckType());
- TypeNode op = hierarchy.typeNode(((Local) ioe.getOp()).getType());
+ TypeNode op = hierarchy.typeNode(ioe.getOp().getType());


        try
          {

There seem to be other cases in the constraint checker where a Local is assumed, and an
exception would be thrown on valid code (that throws a NullPointerException). So, I tried checking one of them:


public class test {
    public void main() {
        int[] array = null;
        System.out.println("array = " + array[0]);
    }
}

And I got a completely different error!
Soot started on Sat Nov 15 22:43:29 PST 2003
Transforming test...
Exception in thread "main" java.lang.RuntimeException: invalid fromType null_typ
e
at soot.baf.internal.BPrimitiveCastInst$1.defaultCase(BPrimitiveCastInst
.java:95)
at soot.TypeSwitch.caseNullType(TypeSwitch.java:106)
at soot.NullType.apply(NullType.java:63)
at soot.baf.internal.BPrimitiveCastInst.getName(BPrimitiveCastInst.java:
91)
at soot.baf.internal.BPrimitiveCastInst.toString(BPrimitiveCastInst.java
:192)
at soot.baf.JasminClass$2.casePrimitiveCastInst(JasminClass.java:1776)
at soot.baf.internal.BPrimitiveCastInst.apply(BPrimitiveCastInst.java:19
8)
at soot.baf.JasminClass.emitInst(JasminClass.java:651)
at soot.baf.JasminClass.emitMethodBody(JasminClass.java:580)
at soot.baf.JasminClass.emitMethod(JasminClass.java:395)
at soot.baf.JasminClass.<init>(JasminClass.java:302)
at soot.Printer.write(Printer.java:225)
at soot.PackManager.writeClass(PackManager.java:499)
at soot.PackManager.writeOutput(PackManager.java:289)
at soot.PackManager.writeOutput(PackManager.java:248)
at soot.Main.run(Main.java:173)
at soot.Main.main(Main.java:152)


And another try;
public class test {
    public static void main(String args[]) {
        int[] array = null;
        System.out.println("array = " + array.length);
    }
}

Gives yet a third error!
Soot started on Sat Nov 15 22:46:49 PST 2003
Transforming test...
Exception in thread "main" java.lang.RuntimeException: soot.jimple.toolkits.typi
ng.TypeException: soot.jimple.toolkits.typing.ConstraintChecker$RuntimeTypeExcep
tion: Type Error(39)
at soot.jimple.toolkits.typing.ConstraintChecker.error(ConstraintChecker
.java:78)
at soot.jimple.toolkits.typing.ConstraintChecker.caseAssignStmt(Constrai
ntChecker.java:717)
at soot.jimple.internal.JAssignStmt.apply(JAssignStmt.java:222)
at soot.jimple.toolkits.typing.ConstraintChecker.check(ConstraintChecker
.java:56)
at soot.jimple.toolkits.typing.TypeResolver.check_and_fix_constraints(Ty
peResolver.java:838)
at soot.jimple.toolkits.typing.TypeResolver.resolve_step_3(TypeResolver.
java:311)
at soot.jimple.toolkits.typing.TypeResolver.resolve(TypeResolver.java:20
3)
at soot.jimple.toolkits.typing.TypeAssigner.internalTransform(TypeAssign
er.java:57)
at soot.BodyTransformer.transform(BodyTransformer.java:51)
at soot.Transform.apply(Transform.java:88)
at soot.JimpleBodyPack.applyPhaseOptions(JimpleBodyPack.java:68)
at soot.JimpleBodyPack.internalApply(JimpleBodyPack.java:116)
at soot.Pack.apply(Pack.java:110)
at soot.coffi.CoffiMethodSource.getBody(CoffiMethodSource.java:115)
at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:79)
at soot.SootMethod.retrieveActiveBody(SootMethod.java:274)
at soot.PackManager.runBodyPacks(PackManager.java:422)
at soot.PackManager.runBodyPacks(PackManager.java:282)
at soot.PackManager.runPacks(PackManager.java:241)
at soot.Main.run(Main.java:172)
at soot.Main.main(Main.java:152)


at soot.jimple.toolkits.typing.ConstraintChecker.check(ConstraintChecker
.java:64)
at soot.jimple.toolkits.typing.TypeResolver.check_and_fix_constraints(Ty
peResolver.java:838)
at soot.jimple.toolkits.typing.TypeResolver.resolve_step_3(TypeResolver.
java:311)
at soot.jimple.toolkits.typing.TypeResolver.resolve(TypeResolver.java:20
3)
at soot.jimple.toolkits.typing.TypeAssigner.internalTransform(TypeAssign
er.java:57)
at soot.BodyTransformer.transform(BodyTransformer.java:51)
at soot.Transform.apply(Transform.java:88)
at soot.JimpleBodyPack.applyPhaseOptions(JimpleBodyPack.java:68)
at soot.JimpleBodyPack.internalApply(JimpleBodyPack.java:116)
at soot.Pack.apply(Pack.java:110)
at soot.coffi.CoffiMethodSource.getBody(CoffiMethodSource.java:115)
at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:79)
at soot.SootMethod.retrieveActiveBody(SootMethod.java:274)
at soot.PackManager.runBodyPacks(PackManager.java:422)
at soot.PackManager.runBodyPacks(PackManager.java:282)
at soot.PackManager.runPacks(PackManager.java:241)
at soot.Main.run(Main.java:172)
at soot.Main.main(Main.java:152)


at soot.jimple.toolkits.typing.TypeResolver.resolve(TypeResolver.java:21
1)
at soot.jimple.toolkits.typing.TypeAssigner.internalTransform(TypeAssign
er.java:57)
at soot.BodyTransformer.transform(BodyTransformer.java:51)
at soot.Transform.apply(Transform.java:88)
at soot.JimpleBodyPack.applyPhaseOptions(JimpleBodyPack.java:68)
at soot.JimpleBodyPack.internalApply(JimpleBodyPack.java:116)
at soot.Pack.apply(Pack.java:110)
at soot.coffi.CoffiMethodSource.getBody(CoffiMethodSource.java:115)
at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:79)
at soot.SootMethod.retrieveActiveBody(SootMethod.java:274)
at soot.PackManager.runBodyPacks(PackManager.java:422)
at soot.PackManager.runBodyPacks(PackManager.java:282)
at soot.PackManager.runPacks(PackManager.java:241)
at soot.Main.run(Main.java:172)
at soot.Main.main(Main.java:152)