soot
soot copied to clipboard
Exception while writing classes
Hello,
I use soot to do the following:
- Load some classes (by setting a process_dir and excluding the ones I don't want from it)
- Build a callgraph
- Write the bytecode using the following code
Options.v().set_output_format(Options.output_format_class);
PackManager.v().writeOutput();
But sometime, I get the following exception, which I think is due to a bug in Soot.
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at org.objectweb.asm.MethodWriter.visitParameterAnnotation(MethodWriter.java:697)
at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:347)
at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:277)
at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:226)
at soot.PackManager.writeClass(PackManager.java:1124)
at soot.PackManager.lambda$1(PackManager.java:705)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "Thread-50" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at org.objectweb.asm.MethodWriter.visitParameterAnnotation(MethodWriter.java:697)
at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:347)
at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:277)
at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:226)
at soot.PackManager.writeClass(PackManager.java:1124)
at soot.PackManager.lambda$1(PackManager.java:705)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at org.objectweb.asm.MethodWriter.visitParameterAnnotation(MethodWriter.java:697)
at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:347)
at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:277)
at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:226)
at soot.PackManager.writeClass(PackManager.java:1124)
at soot.PackManager.lambda$1(PackManager.java:705)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
We're using the latest commit as of today (https://github.com/soot-oss/soot/commit/9d88ffb66380b0b665d2f10810c89e462e72688f) I'm available to provide any more necessary detail!
We are seeing a similar issue and are currently investigating a workaround.
Apr 27, 2023 12:09:11 PM heros.solver.CountingThreadPoolExecutor afterExecute SEVERE: Worker thread execution failed: Index 1 out of bounds for length 1 java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 at org.objectweb.asm.MethodWriter.visitParameterAnnotation(MethodWriter.java:698) at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:348) at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:278) at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:227) at soot.PackManager.writeClass(PackManager.java:1141) at soot.PackManager.lambda$writeOutput$1(PackManager.java:713) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1589)
It appears that within generateMethods
in AbstractASMBackend
there is an overly permissive check on line 339:
if (t instanceof VisibilityParameterAnnotationTag)
which potentially should be:
if (t instanceof VisibilityParameterAnnotationTag && !(t instanceof VisibilityLocalVariableAnnotationTag))