Open intersimone999 opened 7 years ago
@intersimone999 any way you can provide an input class and example Shrike code such that running the code leads to a bad output?
@msridhar I attach all the material you need to replicate the failure. This is the procedure I follow:
I run the JUnit test case "com.ibm.wala.shrikeBT.TestStackMap.testStackMap()" and I get a "instrumented.jar" output file.
I compile the example main class:
javac main.java
I run the main class with the instrumented jar with the command:
java -cp instrumented.jar:. main
The output I get is:
Exception in thread "main" java.lang.ClassFormatError: StackMapTable format error: reserved frame type
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at main.main(main.java:3)
Instead, the expected output is:
Hello world
Which is the output I get if I run java -cp mysql-connector-java-6.0.6.jar:. main
Hello.
I'm using Shrike to instrument bytecode. Specifically, I need to add some instructions before return statements. For example (in Java):
return x;
would become something like:where
newvar
in Bytecode has, as index, the maximum local variable index used in the method + 1. For example, if the method uses 5 local variables (from 0 to 4), i use 5 to indicate "newvar".This seems to work fine in general, but I'm having troubles with the method "executeQuery(java.lang.String)" of the class
com.mysql.cj.jdbc.StatementImpl
of MySQL drivers for JDBC version 6.0.6. In this case, when I run the instrumented code, I get ajava.lang.ClassFormatError:StackMapTable format error: reserved frame type
.Actually, if I run
javap
on the instrumented class, instead of printing the StackMapTable, it prints this:All the other method, instead, have something like this:
So, in conclusion, there is some problem in the instrumentation. I think the problem is related to the introduction of the new variable. At the moment, I just use a new index, but I don't specify anywhere that this new variable is there. For some reason, Shrike is not able to correctly compute the StackMapTable in this case. It may be that I'm doing something wrong. What do you suggest? Note that I need the new variable, so removing it is not an option.
PS: You can find attached the instrumented class. StatementImpl.zip
EDIT: I confirm that the problem is related to WALA. Instead of adding the above-mentioned code, I tried to add just a call to a void method in the same locations, and the problem is still there. Here the class instrumented with the trivial call: StatementImpl.zip