SpoonLabs / astor

Automatic program repair for Java with generate-and-validate techniques :v::v:: jGenProg (2014) - jMutRepair (2016) - jKali (2016) - DeepRepair (2017) - Cardumen (2018) - 3sfix (2018)
https://hal.archives-ouvertes.fr/hal-01321615/document
GNU General Public License v2.0
205 stars 107 forks source link

Issue with running jGenprog with bug from defects4j #370

Open Fibien opened 5 months ago

Fibien commented 5 months ago

Hello, I’m currently a bit stuck with trying to use jGenprog to fix a bug from defects4j.

I have installed astor and successfully run the jGenprog example code from getting started. (With the following)

cd examples/Math-issue-280 mvn clean compile test -DskipTests # compiling and running bug example cd ../../ java -cp target/astor-*-jar-with-dependencies.jar fr.inria.main.evolution.AstorMain -mode jgenprog -srcjavafolder /src/java/ -srctestfolder /src/test/ -binjavafolder /target/classes/ -bintestfolder /target/test-classes/ -location /home/user/astor/examples/Math-issue-280/ -dependencies examples/Math-issue-280/lib

I have also installed and successfully run the defects4j example. I have checked out, compiled and tested using the example code on their git.

Now to the problem. I have checked out and compiled bug 40 from Math in defects4j and stored the bug in /tmp/bug/40/ and when I try to run jGenprog using this the command below, I get following error:

Error: Could not find or load main class fr.inria.main.evolution.AstorMain

The command used sudo java -cp /home/project/astor-*-jar-with-dependencies.jar fr.inria.main.evolution.AstorMain -mode jgenprog -srcjavafolder /src/java/ -srctestfolder /src/test/ -binjavafolder /target/classes/ -bintestfolder /target/test-classes/ -location /tmp/math/40 -stopfirst true

I have compiled the bug folder using the compile command in defects4j and mvn clean compile test -DskipTests. Have encountered the same error in both cases.

Does anyone know what might be the issue? Any advice on how to extract bugs from defects4j and create and verify patches using jGenprog would be appreciated.

monperrus commented 5 months ago

your classpath is likely wrong, "|/home/project/astor-*-jar-with-dependencies.jar|" does not resolve to anything.

Fibien commented 5 months ago

Thank you, that was the issue.

Having read "Astor: Exploring the Design Space of Generate-and-Validate Program Repair beyond GenProg," I discovered that there were two implemented navigation strategies for jGenprog: selective and evolution. However, I couldn't find out how to select the evolution strategy as the navigation strategy for jGenprog, neither among the arguments provided here nor using help in the terminal. How does one select the evolution strategy as the navigation strategy for jGenprog?

While examining the implementation of jGenprog, I noticed there was a check to determine if the crossover operation should be applied. Should one change the setting in astor.properties (applyCrossover=true) to make jGenprog apply the crossover operator? Or what is the intended method to make jGenprog apply the crossover operator?

Thank you again for the help and the answers.

monperrus commented 5 months ago

ping @martinezmatias

martinezmatias commented 5 months ago

Hi @Fibien

How does one select the evolution strategy as the navigation strategy for jGenprog?

You can implicitly select the strategy by considering more than program variant to evolve (i.e., the population). By default we use one. The population can be controlled with the param population. There are other propertiesfor the evolution strategy that can be configured (e.g. mutationrate).

Since in our experiments we have executed jGenProg in the selective mode (mostly for a matter of scalability), we dont have a clear interface for the evolutionary mode. For that reason, we have not played enough with the crossover functionality.

I open an issue to implement a clear interface for the two modes. Please, feel free to propose a PR of that implementation. (I don't have time for implement it right now, but I can help you).

Regards Matias

Fibien commented 5 months ago

Thank you for the answer Matias. Would invoking jGenprog with another value for population or mutationrate make jGenprog use evolution strategy and the crossover functionality?

Would it be possible to combine the selective strategy with the crossover functionality? For example by removing the conditional check in jGenprog and directly run ‘applyCrossover’? Would the crossover functionality work the same with selective navigation strategy as it would with evolutionary navigation strategy?

Thanks again for all the help.