resess / Slicer4J

Slicer4J is an accurate, low-overhead dynamic slicer for Java programs.
MIT License
38 stars 17 forks source link

Instructions to run on more Defects4J projects #33

Closed thanhlecongg closed 7 months ago

thanhlecongg commented 10 months ago

Hi @khaled-e-a,

I wonder if you can kindly advise me on how to create a suitable jar for Slicer4J from Defects4J. I have tried to compile a Defects4J project using their "defects4j compile" and then create a jar using jar cf but it seems to be not working. Particularly, when using jar produced by jar cf, I got nothing from the trace log. I guess there may be some mismatch leading to my produced jar are not compatible with Slicer4J. I'd really appreciate it if you could share the way you construct your benchmark projects.

Thank you very much.

Best regards, Thanh

khaled-e-a commented 10 months ago

Hi @thanhlecongg

Thank you for your interest in Slicer4J! Using the "defects4j compile" is the right way, did you check that the compiled defects4j jar works first before slicing it? Can you also please share more details about what is not working, like are you running the slicer4j.py script or using the Slicer4J JAR? which command did you use? what are the outputs you got? etc.

Thank you.

thanhlecongg commented 10 months ago

Hi @khaled-e-a, thank you for your kind advise. Please see more details as follows:

  1. About jar file, I have constructed by run the following commands:
    
    # Compile defects4j project
    defects4j compile

Build jar file from classes

jar cf jd.jar target/classes/ target/test-classes/

to create "jd.jar" file. I have checked it run correctly using the following command: 

java -cp "JacksonDatabind_3b/jd.jar:JacksonDatabind_3b/target/test-classes/:JacksonDatabind_3b/target/dependency/*:JacksonDatabind_3b/target/classes/" org.junit.runner.JUnitCore com.fasterxml.jackson.databind.deser.TestArrayDeserialization

and got the similar output of Defects4J, i.e. a failure of NullPointerException. However, compared to the [command](https://github.com/resess/Slicer4J/blob/main/benchmarks/run_benchmarks.py#L93) used in your code, I need add one more classpath, i.e.,  JacksonDatabind_3b/target/classes/

2. When I run slicer4J using https://github.com/resess/Slicer4J/blob/main/benchmarks/run_benchmarks.py. I got nothing results from trace.log_icdg.log, making it fail on line [145](https://github.com/resess/Slicer4J/blob/main/benchmarks/run_benchmarks.py#L145). I have tried to debug and found that it happens as [instrumentation command](https://github.com/resess/Slicer4J/blob/main/benchmarks/run_benchmarks.py#L109) failed with the following error: 

[main] INFO Slicer - main (216): Started Slicer4J [main] INFO JimpleWriter - initialize (17): Initializing Instrumenter [main] INFO JimpleWriter - initialize (30): Initialization done [main] INFO JimpleWriter - start (37): Running packs ... [main] INFO JimpleWriter - start (39): Writing output ... [main] INFO JimpleWriter - start (41): Output written ... [main] INFO JavaInstrumenter - initialize (72): Initializing Instrumenter [main] INFO JavaInstrumenter - initialize (92): Initialization done [main] INFO JavaInstrumenter - start (247): Running packs ... [Thread-58] ERROR heros.solver.CountingThreadPoolExecutor - Worker thread execution failed: null java.lang.NullPointerException at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.basicBlockInstrument(InstrumenterUtils.java:128) at ca.ubc.ece.resess.slicer.dynamic.slicer4j.instrumenter.JavaInstrumenter$2.internalTransform(JavaInstrumenter.java:177) at soot.BodyTransformer.transform(BodyTransformer.java:47) at soot.Transform.apply(Transform.java:126) at soot.BodyPack.internalApply(BodyPack.java:49) at soot.Pack.apply(Pack.java:126) at soot.PackManager.runBodyPacks(PackManager.java:991) at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:667) 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) Exception in thread "main" Exception in thread "Thread-58" java.lang.NullPointerException at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.basicBlockInstrument(InstrumenterUtils.java:128) at ca.ubc.ece.resess.slicer.dynamic.slicer4j.instrumenter.JavaInstrumenter$2.internalTransform(JavaInstrumenter.java:177) at soot.BodyTransformer.transform(BodyTransformer.java:47) at soot.Transform.apply(Transform.java:126) at soot.BodyPack.internalApply(BodyPack.java:49) at soot.Pack.apply(Pack.java:126) at soot.PackManager.runBodyPacks(PackManager.java:991) at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:667) 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.NullPointerException at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.basicBlockInstrument(InstrumenterUtils.java:128) at ca.ubc.ece.resess.slicer.dynamic.slicer4j.instrumenter.JavaInstrumenter$2.internalTransform(JavaInstrumenter.java:177) at soot.BodyTransformer.transform(BodyTransformer.java:47) at soot.Transform.apply(Transform.java:126) at soot.BodyPack.internalApply(BodyPack.java:49) at soot.Pack.apply(Pack.java:126) at soot.PackManager.runBodyPacks(PackManager.java:991) at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:667) 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'm guessing that my jar there is something different from your jar, making Slicer4J run wrongly. 

Thank you very much. Have a nice day.
khaled-e-a commented 10 months ago

Thank you @thanhlecongg, can you please attach the jar file (or email it to me) so I can replicate the issue?

Thank you.

thanhlecongg commented 10 months ago

Hi,

This is my jar file for JacksonDatabind-3b.

Thank you, Thanh

thanhlecongg commented 10 months ago

Hi @khaled-e-a,

Can you replicate the error?

Bests, Thanh

khaled-e-a commented 7 months ago

Hi @thanhlecongg Appologies for the late response as I got busy with other projects.

There were issues with compiling benchmarks with declared Java compiler version 1.6, I bumed all those benchmarks to 1.7 in the latest commit d7b6c5b, including the JacksonDatabind-3b which now compiles successfully.

You should be able to compile and run all benchmarks successfully, including JacksonDatabind-3b, using python3 run_benchmarks.py

Closing this issue now as it should be fixed, please re-open if you still face this problem.