soot-oss / soot

Soot - A Java optimization framework
GNU Lesser General Public License v2.1
2.88k stars 708 forks source link

Index out of bounds when instrumenting Android app #1143

Open skull591 opened 5 years ago

skull591 commented 5 years ago

Hi.

I was trying to use soot to instrument an Android app AntennaPod, but the IndexOutOfBoundsException keeps showing when transforming classes back to dex file. I was trying to add a Log.v() statement before each invocation statement. Here is the stack trace:

Exception in thread "Thread-17" java.lang.IndexOutOfBoundsException: Index: 4579, Size: 4579 at java.util.ArrayList.rangeCheck(ArrayList.java:657) at java.util.ArrayList.get(ArrayList.java:433) at soot.toDex.StmtVisitor.reduceInstructions(StmtVisitor.java:285) at soot.toDex.StmtVisitor.finalizeInstructions(StmtVisitor.java:228) at soot.toDex.DexPrinter.toInstructions(DexPrinter.java:1513) at soot.toDex.DexPrinter.toMethodImplementation(DexPrinter.java:1174) at soot.toDex.DexPrinter.toMethods(DexPrinter.java:1083) at soot.toDex.DexPrinter.addAsClassDefItem(DexPrinter.java:656) at soot.toDex.DexPrinter.add(DexPrinter.java:1646) at soot.PackManager.writeClass(PackManager.java:1096) at soot.PackManager.lambda$writeOutput$1(PackManager.java:699) 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) java.lang.IndexOutOfBoundsException: Index: 4579, Size: 4579 at java.util.ArrayList.rangeCheck(ArrayList.java:657) at java.util.ArrayList.get(ArrayList.java:433) at soot.toDex.StmtVisitor.reduceInstructions(StmtVisitor.java:285) at soot.toDex.StmtVisitor.finalizeInstructions(StmtVisitor.java:228) at soot.toDex.DexPrinter.toInstructions(DexPrinter.java:1513) at soot.toDex.DexPrinter.toMethodImplementation(DexPrinter.java:1174) at soot.toDex.DexPrinter.toMethods(DexPrinter.java:1083) at soot.toDex.DexPrinter.addAsClassDefItem(DexPrinter.java:656) at soot.toDex.DexPrinter.add(DexPrinter.java:1646) at soot.PackManager.writeClass(PackManager.java:1096) at soot.PackManager.lambda$writeOutput$1(PackManager.java:699) 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)

I searched past issues and found that you claim that it was fixed #1135 . So am I doing it wrong?

mbenz89 commented 5 years ago

Which version of Soot are you using? The fix was just applied in the develop branch and will thus just work for Soot's SNAPSHOT versions for now.

skull591 commented 5 years ago

I see...I'm using version 3.3.0 via Gradle. Is there any way to use SNAPSHOT version via Gradle? I tried 3.3.0-SNAPSHOT but it's not working..

mbenz89 commented 5 years ago

You should be able to acquire 3.3.0-SNAPSHOT from Maven Central's snapshot repository: https://oss.sonatype.org/content/repositories/snapshots/ca/mcgill/sable/soot/

I'm not a Gradle user and thus cannot help you with the Gradle specifics here...