themaplelab / averroes

Java bytecode generator for sound and precise partial program analysis
Eclipse Public License 2.0
23 stars 7 forks source link

Runtime Exception because Soot could not find a method #19

Open akshayutture opened 3 years ago

akshayutture commented 3 years ago

I ran Averroes on the NJR dataset, and it crashes for approximately 60 of 293 benchmarks.

Here is a sample Jar file for which it crashes. https://drive.google.com/file/d/1-YaqC0epGlt8pDF2yrqMW78SI2WFfC6s/view?usp=sharing

Here is the command used to run Averroes

java -jar averroes/build/libs/averroes-all-1.0-SNAPSHOT.jar -a input.jar -j /usr/lib/jvm/java-8-openjdk-amd64/jre -o output2 -m nui.squirt.demo.DemoSquirtApplication -r "WiiMoteTest:WiiMoteTest$1:WiiMoteTest$2:WiiMoteTest$Particle:WiiMoteTest$ParticleSystem:nui.squirt.Actionable:nui.squirt.Component:nui.squirt.Container:nui.squirt.ControlPoint:nui.squirt.ControlPointListener:nui.squirt.Keyboard:nui.squirt.NUIController:nui.squirt.NUIController$SquirtPApplet:nui.squirt.TextInput:nui.squirt.Valuable:nui.squirt.component.AbstractActionable:nui.squirt.component.AbstractComponent:nui.squirt.component.AbstractContainer:nui.squirt.component.AbstractValuable:nui.squirt.component.Button:nui.squirt.component.Circle:nui.squirt.component.Frame:nui.squirt.component.Image:nui.squirt.component.Knob:nui.squirt.component.Label:nui.squirt.component.PhysicsCircle:nui.squirt.component.PhysicsComponent:nui.squirt.component.PhysicsRectangle:nui.squirt.component.Rectangle:nui.squirt.component.Slider:nui.squirt.component.TextField:nui.squirt.controlpoint.AbstractControlPoint:nui.squirt.controlpoint.MouseControlPoint:nui.squirt.controlpoint.TUIOControlPoint:nui.squirt.demo.DemoSquirtApplication:nui.squirt.demo.DemoSquirtApplication$1:nui.squirt.demo.DemoSquirtApplication$SlidingSlider:nui.squirt.demo.DemoSquirtApplication$SpinningRectangle:nui.squirt.demo.DemoSquirtApplication$SpinningScalingImage:nui.squirt.demo.DemoSquirtApplication$ValueLabel:nui.squirt.event.ActionEvent:nui.squirt.event.Event:nui.squirt.event.KeyEvent:nui.squirt.event.TextEvent:nui.squirt.event.ValueEvent:nui.squirt.listener.ActionListener:nui.squirt.listener.KeyListener:nui.squirt.listener.TextListener:nui.squirt.listener.ValueListener"

Here is the Averroes output

Organizing the JAR files...
Processing input archive: /home/akshayutture/projects/averroes_trial/input.jar
Processing library archive: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jsse.jar
Processing library archive: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar
Processing library archive: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jce.jar
# application classes: 39
# library classes: 21357

Loading classes...
Soot loaded the input classes in 1.02 seconds.

Creating the class hierarchy for the placeholder library...
# initial application classes: 39
# initial library classes: 114
# initial library methods: 3480
# initial library fields: 1183
# referenced library methods: 117
# referenced library fields: 28

Cleaning up the class hierarchy...
# removed library methods: 3151
# removed library fields: 1155
# final library methods: 359
# final library fields: 28

Generating extra library classes...
# generated library classes: 4
# generated library methods: 11

Creating the skeleton for Averroes's main library class...
Generating the method bodies for the placeholder library classes ...
java.lang.RuntimeException: No method void <init>() in class nui.squirt.component.Rectangle
    at soot.SootClass.getMethod(SootClass.java:373)
    at soot.SootClass.getMethod(SootClass.java:414)
    at averroes.soot.Hierarchy.getDirectSuperclassDefaultConstructor(Hierarchy.java:531)
    at averroes.soot.AverroesJimpleBody.insertStandardJimpleBodyHeader(AverroesJimpleBody.java:139)
    at averroes.soot.AverroesJimpleBody.createBasicJimpleBody(AverroesJimpleBody.java:117)
    at averroes.soot.AverroesJimpleBody.<init>(AverroesJimpleBody.java:87)
    at averroes.soot.CodeGenerator.createJimpleBody(CodeGenerator.java:303)
    at averroes.soot.CodeGenerator.createLibraryMethodBodies(CodeGenerator.java:276)
    at averroes.Main.main(Main.java:130)
karimhamdanali commented 3 years ago

hi @akshayutture. Is that the same output/error that you get for all those 60 benchmarks?

akshayutture commented 3 years ago

Hi @karimhamdanali, Actually it is not the same error for all 60 benchmarks. I am sorry I didn't realize that earlier.

I think I see 3 distinct kinds of errors.

1) Missing some no-argument constructor in some class (as in the example shown above)

2) Some method (like 'calculate' in the example below) is not declared.

java.lang.RuntimeException: not declared: calculate
        at soot.SootMethod.getDeclaringClass(SootMethod.java:177)
        at averroes.soot.CodeGenerator.callApplicationMethodsReflectively(CodeGenerator.java:578)
        at averroes.soot.CodeGenerator.createAverroesLibraryDoItAll(CodeGenerator.java:538)
        at averroes.soot.CodeGenerator.createAverroesLibraryClass(CodeGenerator.java:259)
        at averroes.Main.main(Main.java:126)

3) Error involving resolving level (example below)

Creating the class hierarchy for the placeholder library...
Exception in thread "main" java.lang.ExceptionInInitializerError
        at averroes.Main.main(Main.java:88)
Caused by: java.lang.RuntimeException: This operation requires resolving level SIGNATURES but java.util.Calendar is at resolving level DANGLING
If you are extending Soot, try to add the following call before calling soot.Main.main(..):
Scene.v().addBasicClass(java.util.Calendar,SIGNATURES);
Otherwise, try whole-program mode (-w).
        at soot.SootClass.checkLevelIgnoreResolving(SootClass.java:183)
        at soot.SootClass.checkLevel(SootClass.java:165)
        at soot.SootClass.getMethodUnsafe(SootClass.java:546)
        at soot.SootMethodRefImpl.tryResolve(SootMethodRefImpl.java:210)
        at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:263)
        at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:183)
        at averroes.util.BytecodeUtils.makeSootMethod(BytecodeUtils.java:75)
        at org.objectweb.asm.AsmAverroesApplicationConstantPool.findLibraryMethodsInConstantPool(AsmAverroesApplicationConstantPool.java:141)
        at org.objectweb.asm.AsmAverroesApplicationConstantPool.findLibraryMethodsInApplicationConstantPool(AsmAverroesApplicationConstantPool.java:282)
        at org.objectweb.asm.AsmAverroesApplicationConstantPool.initialize(AsmAverroesApplicationConstantPool.java:113)
        at org.objectweb.asm.AsmAverroesApplicationConstantPool.<init>(AsmAverroesApplicationConstantPool.java:39)
        at averroes.soot.Hierarchy.findLibraryEntitiesReferencedInApplication(Hierarchy.java:1699)
        at averroes.soot.Hierarchy.initialize(Hierarchy.java:1550)
        at averroes.soot.Hierarchy.<init>(Hierarchy.java:150)
        at averroes.soot.Hierarchy.<clinit>(Hierarchy.java:26)
        ... 1 more

I can send you the errors logs from all the benchmarks if necessary.

I understand that all these errors could potentially be very time consuming to debug. If that is the case, we can postpone the fixes to a later date.

karimhamdanali commented 3 years ago

Hi @akshayutture. Thanks for clarifying that. Issues 1 and 3 seem related, and I think I know how to fix them. I'll have some time to fix both in a couple of weeks.

Issue 2 is the one that I'd need to debug further to know why it is happening. If you have any further details about this one, I'd greatly appreciate it.

Sharing the error logs from the benchmarks might help. Also, if you can point me to where I can download and analyze/run these benchmarks for testing, that would be great.

Thanks.

akshayutture commented 3 years ago

Here are the error logs averroes.log

The benchmarks themselves are available here (https://zenodo.org/record/4839913#.YOykQS1h0UQ)

Here is the script used to run Averroes on the benchmark set https://drive.google.com/file/d/1entiZGMjPDiBEufQPpi6FwlYPICLe0aG/view?usp=sharing

As of now, I don't have any insight as to why Issue 2 might be occurring, but I shall try to investigate some more.

karimhamdanali commented 3 years ago

Thanks Akshay. I have some time to look into those issues over the next week or two. I'll keep you posted as I hopefully resolve them! Thanks for sharing the logs as I'm sure they will be relevant to debugging the issues that you raised.

akshayutture commented 3 years ago

Thank you for taking the time out to look into the issues. Do let me know if I can provide anything further.