Repository: soot-oss/soot

Issue #809: NullPointerException when retrieving body
Created: 2017-11-01T13:21:54Z
I've got a few apks that fail with:
java.lang.NullPointerException
	at soot.jimple.toolkits.typing.fast.UseChecker.caseAssignStmt(UseChecker.java:362)
	at soot.jimple.internal.JAssignStmt.apply(JAssignStmt.java:238)
	at soot.jimple.toolkits.typing.fast.UseChecker.check(UseChecker.java:125)
	at soot.jimple.toolkits.typing.fast.TypeResolver.insertCasts(TypeResolver.java:426)
	at soot.jimple.toolkits.typing.fast.TypeResolver.minCasts(TypeResolver.java:437)
	at soot.jimple.toolkits.typing.fast.TypeResolver.inferTypes(TypeResolver.java:158)
	at soot.jimple.toolkits.typing.TypeAssigner.internalTransform(TypeAssigner.java:125)
	at soot.BodyTransformer.transform(BodyTransformer.java:59)
	at soot.BodyTransformer.transform(BodyTransformer.java:64)
	at soot.dexpler.DexBody.jimplify(DexBody.java:650)
	at soot.dexpler.DexMethod$1.getBody(DexMethod.java:146)
	at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:126)
	at soot.SootMethod.retrieveActiveBody(SootMethod.java:385)

Is there something that can be done when the type cannot be reconstructed?

Duplicate issue #867: Soot crashed in a simple Java source
Created: 2018-01-12T08:25:53Z
Hi all,
Our code scanner has found a Null Pointer Exception for the following case:
// Main.java
public class Main {
  public int numTrees(int n) {
    int[] dp = null;
    return dp[0];
  }
}

Reproduction:
Use soot
java -cp <path-to-sootclasses-trunk-jar-with-dependencies.jar> soot.Main -cp .:${JAVA_HOME}/jre/lib/rt.jar -f jimple Main
It should raise an exception:
java.lang.RuntimeException: Failed to apply jb to <Main: int numTrees(int)>
    at soot.asm.AsmMethodSource.getBody(AsmMethodSource.java:1911)
    at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:126)
    at soot.SootMethod.retrieveActiveBody(SootMethod.java:385)
    at soot.PackManager$3.run(PackManager.java:1216)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at soot.jimple.toolkits.typing.fast.UseChecker.caseAssignStmt(UseChecker.java:362)
    at soot.jimple.internal.JAssignStmt.apply(JAssignStmt.java:238)
    at soot.jimple.toolkits.typing.fast.UseChecker.check(UseChecker.java:125)
    at soot.jimple.toolkits.typing.fast.TypeResolver.insertCasts(TypeResolver.java:426)
    at soot.jimple.toolkits.typing.fast.TypeResolver.minCasts(TypeResolver.java:437)
    at soot.jimple.toolkits.typing.fast.TypeResolver.inferTypes(TypeResolver.java:158)
    at soot.jimple.toolkits.typing.TypeAssigner.internalTransform(TypeAssigner.java:126)
    at soot.BodyTransformer.transform(BodyTransformer.java:54)
    at soot.Transform.apply(Transform.java:105)
    at soot.JimpleBodyPack.applyPhaseOptions(JimpleBodyPack.java:73)
    at soot.JimpleBodyPack.internalApply(JimpleBodyPack.java:105)
    at soot.Pack.apply(Pack.java:125)
    at soot.asm.AsmMethodSource.getBody(AsmMethodSource.java:1909)
    ... 6 more

Regards,
Sourcebrella Inc.

Closing comment (2018-01-19T13:24:57Z): This seems to be the same bug as reported in #809.