Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle static interface methods as entrypoints (#1275)
When a static Interface method is selected as an Entrypoint, WALA creates an invokeinterface instead of an invokestatic instruction in FakeRootMethod. This will lead to an out-of-array read when resolving the receiver for an interface invocation. A test can be simply an Android app generated by Android Studio for a Basic Activity demo (either Java or Kotlin). In my case, the problem occurs for handling: 40149 = invokeinterface < Application, Landroidx/window/layout/WindowMetricsCalculator, getOrCreate()Landroidx/window/layout/WindowMetricsCalculator; > @32353 exception:40150 And the exception is as follows: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.lambda$getTargetsForCall$0(SSAPropagationCallGraphBuilder.java:2072) at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder$CrossProductRec.rec(SSAPropagationCallGraphBuilder.java:542) at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.iterateCrossProduct(SSAPropagationCallGraphBuilder.java:2055) at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.getTargetsForCall(SSAPropagationCallGraphBuilder.java:2079) at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder$ConstraintVisitor.visitInvokeInternal(SSAPropagationCallGraphBuilder.java:1159) at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder$ConstraintVisitor.visitInvoke(SSAPropagationCallGraphBuilder.java:1115) at com.ibm.wala.ssa.SSAInvokeInstruction.visit(SSAInvokeInstruction.java:94) at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.addBlockInstructionConstraints(SSAPropagationCallGraphBuilder.java:273) at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.addNodeInstructionConstraints(SSAPropagationCallGraphBuilder.java:250) at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.unconditionallyAddConstraintsFromNode(SSAPropagationCallGraphBuilder.java:226) at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.addConstraintsFromNode(SSAPropagationCallGraphBuilder.java:191) at com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder.addConstraintsFromNewNodes(PropagationCallGraphBuilder.java:308) at com.ibm.wala.ipa.callgraph.propagation.StandardSolver.solve(StandardSolver.java:53) at com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder.makeCallGraph(PropagationCallGraphBuilder.java:248) This commit prioritizes a static method over an interface method and addresses the above problem. --------- Co-authored-by: Manu Sridharan <[email protected]>
- Loading branch information