Skip to content

The issue with the ARDiff testing program reporting errors. #3

@LuMingYinDetect

Description

@LuMingYinDetect

Hello! I've utilized ARDiff to test a program I've written myself. Below is the old version of the program:
public class oldV{ public static int snippet(int num, int den) { int ratio; if (num < 0 || den < 0) { ratio = -1; } else if (den == 0 || num == 0) { ratio = 0; } else if (den > 200 || num > 200) { ratio = 200; } else if (den < 2) { ratio = 2 * num; } else if (den < 4) { ratio = num - den; } else if (den < 8) { if (num < den) { ratio = num; } else { ratio = den; } } else if (den < 16) { if (num > den) { ratio = num; } else { ratio = den; } } else if (den < 32) { ratio = 32; for (int i = 2; i < 32; i++) { if (num % i == 0) { ratio = i; break; } } } else if (den < 64) { ratio = 64; for (int i = 2; i < 64; i++) { if (den % i == 0) { ratio = i; break; } } } else if (den < 128) { int x = den; int y = num; int z = x + y; for (int i = 1; i < 30; i++) { z = x + y; x = y; y = z; } ratio = z; } else { ratio = den + num + 10; } return ratio; } }

The new version of the code is as follows:
public class newV{ public static int snippet(int num, int den) { int ratio; if (num < 0 || den < 0) { ratio = -1; } else if (den == 0 || num == 0) { ratio = 0; } else if (den > 200 || num > 200) { ratio = 200; } else if (den < 2) { ratio = 2 * num; } else if (den < 4) { ratio = num - den; } else if (den < 8) { if (num < den) { ratio = num; } else { ratio = den; } } else if (den < 16) { if (num > den) { ratio = num; } else { ratio = den; } } else if (den < 32) { ratio = 32; for (int i = 2; i < 32; i++) { if (num % i == 0) { ratio = i; break; } } } else if (den < 64) { ratio = 64; for (int i = 2; i < 64; i++) { if (den % i == 0) { ratio = i; break; } } } else if (den < 128) { int x = den; int y = num; int z = x + y; for (int i = 1; i < 30; i++) { z = x + y; x = y; y = z; } ratio = y; } else { ratio = den + num + 10; } return ratio; } }

When I use IMP-S to test the code, IMP-S can provide correct results. However, when I use DSE and ARDiff to test the program, the tools report errors as follows:
`*****************************************************************************
------------------------------------ARDIFF-----------------------------------


An error/exception occurred when instrumenting the files or running the equivalence checking. Please report this issue to us.

java.io.IOException: Compilation error: Compilation error: cannot find symbol
symbol: variable ratio
location: class demo.benchmarks.Airy.Sign.Eq.instrumented.IoldVARDiffcannot find symbol
symbol: variable ratio
location: class demo.benchmarks.Airy.Sign.Eq.instrumented.IoldVARDiff
at equiv.checking.Utils.compile(Utils.java:69)
at equiv.checking.Instrumentation.saveNewProcedure(Instrumentation.java:312)
at DSE.DSE.runEquivalenceChecking(DSE.java:272)
at GradDiff.GradDiff.runTool(GradDiff.java:90)
at Runner.Runner.runTool(Runner.java:163)
at Runner.Runner.main(Runner.java:472)`

The detection instructions I used are:java -Djava.library.path=jpf-git/jpf-symbc/lib -jar target/artifacts/Implementation_jar/Implementation.jar --path1 /project/ARDiff/benchmarks/Airy/Sign/Eq/oldV.java --path2 /project/ARDiff/benchmarks/Airy/Sign/Eq/newV.java --tool A --s coral --b 3

I replaced the files in the /benchmarks/Airy/Sign/Eq directory of the test suite with my own code. Therefore, the error message indicates that the error occurred in the demo.benchmarks.Airy.Sign.Eq directory.

The error message indicates that the symbol "ratio" was not found. I attempted to redefine "ratio" within the function snippet instead of as a standalone entity. Here is an example of how it is done:
'public class oldV{
public static int snippet(int num, int den,int ratio) {
if (num < 0 || den < 0) {
ratio = -1;
} else if (den == 0 || num == 0) {
ratio = 0;
} else if (den > 200 || num > 200) {
ratio = 200;
} else if (den < 2) {
ratio = 2 * num;
} else if (den < 4) {
ratio = num - den;
} else if (den < 8) {
if (num < den) {
ratio = num;
} else {
ratio = den;
}
} else if (den < 16) {
if (num > den) {
ratio = num;
} else {
ratio = den;
}
} else if (den < 32) {
ratio = 32;
for (int i = 2; i < 32; i++) {
if (num % i == 0) {
ratio = i;
break;
}
}
} else if (den < 64) {
ratio = 64;
for (int i = 2; i < 64; i++) {
if (den % i == 0) {
ratio = i;
break;
}
}
} else if (den < 128) {
int x = den;
int y = num;
int z = x + y;
for (int i = 1; i < 30; i++) {
z = x + y;
x = y;
y = z;
}
ratio = z;
} else {
ratio = den + num + 10;
}
return ratio;
}
}'

After making this modification, ARDiff no longer reports this error. Do you happen to know the reason behind this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions