defects4j icon indicating copy to clipboard operation
defects4j copied to clipboard

Discrepancy between Math 38 in V2.0.0 and V3.0.1

Open SaraBaradaran opened this issue 8 months ago • 1 comments

Hi, I found a discripancy between Math 38 in two different versions. I'm employing Soot framework to get failing traces and when I instrument failing test case of Math 38 in V2.0.0 the failure happens in 255- : specialinvoke r5.<org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest: void doTest(org.apache.commons.math.analysis.MultivariateFunction,double[],double[][],org.apache.commons.math.optimization.GoalType,double,double,int,int,org.apache.commons.math.optimization.RealPointValuePair,java.lang.String)>($r6, r0, r1, $r8, 1.0E-12, 1.0E-6, 2000, i1, r4, $r11), which is correct. This is the Jimple code of the test case org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest::testConstrainedRosenWithMoreInterpolationPoints

-1- : r5 := @this: org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest
243- : r0 = staticinvoke <org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest: double[] point(int,double)>(13, 0.1)
244- : r1 = staticinvoke <org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest: double[][] boundaries(int,double,double)>(13, -1.0, 2.0)
245- : $r2 = new org.apache.commons.math.optimization.RealPointValuePair
245- : $r3 = staticinvoke <org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest: double[] point(int,double)>(13, 1.0)
245- : specialinvoke $r2.<org.apache.commons.math.optimization.RealPointValuePair: void <init>(double[],double)>($r3, 0.0)
245- : r4 = $r2
252- : b0 = 47
254- : i1 = 1
254- : if i1 > 47 goto return
255- : $r6 = new org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest$Rosen
255- : specialinvoke $r6.<org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest$Rosen: void <init>(org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest$1)>(null)
255- : $r8 = <org.apache.commons.math.optimization.GoalType: org.apache.commons.math.optimization.GoalType MINIMIZE>
255- : $r7 = new java.lang.StringBuilder
255- : specialinvoke $r7.<java.lang.StringBuilder: void <init>()>()
255- : $r9 = virtualinvoke $r7.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("num=")
255- : $r10 = virtualinvoke $r9.<java.lang.StringBuilder: java.lang.StringBuilder append(int)>(i1)
255- : $r11 = virtualinvoke $r10.<java.lang.StringBuilder: java.lang.String toString()>()
255- : specialinvoke r5.<org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest: void doTest(org.apache.commons.math.analysis.MultivariateFunction,double[],double[][],org.apache.commons.math.optimization.GoalType,double,double,int,int,org.apache.commons.math.optimization.RealPointValuePair,java.lang.String)>($r6, r0, r1, $r8, 1.0E-12, 1.0E-6, 2000, i1, r4, $r11)
254- : i1 = i1 + 1
254- : goto [?= (branch)]
262- : return

when I instrument failing test case of Math 38 in V3.0.1 the failure happens in 255- : specialinvoke $r6.<org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest$Rosen: void <init>()>(), which is a wrong place. This is the Jimple code of the test case org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest::testConstrainedRosenWithMoreInterpolationPoints

-1- : r5 := @this: org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest
243- : r0 = staticinvoke <org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest: double[] point(int,double)>(13, 0.1)
244- : r1 = staticinvoke <org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest: double[][] boundaries(int,double,double)>(13, -1.0, 2.0)
245- : $r2 = new org.apache.commons.math.optimization.RealPointValuePair
245- : $r3 = staticinvoke <org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest: double[] point(int,double)>(13, 1.0)
245- : specialinvoke $r2.<org.apache.commons.math.optimization.RealPointValuePair: void <init>(double[],double)>($r3, 0.0)
245- : r4 = $r2
252- : b0 = 47
254- : i1 = 1
254- : if i1 > 47 goto return
255- : $r6 = new org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest$Rosen
255- : specialinvoke $r6.<org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest$Rosen: void <init>()>()
255- : $r7 = <org.apache.commons.math.optimization.GoalType: org.apache.commons.math.optimization.GoalType MINIMIZE>
255- : $r8 = dynamicinvoke "makeConcatWithConstants" <java.lang.String (int)>(i1) <java.lang.invoke.StringConcatFactory: java.lang.invoke.CallSite makeConcatWithConstants(java.lang.invoke.MethodHandles$Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.String,java.lang.Object[])>("num=\u0001")
255- : virtualinvoke r5.<org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest: void doTest(org.apache.commons.math.analysis.MultivariateFunction,double[],double[][],org.apache.commons.math.optimization.GoalType,double,double,int,int,org.apache.commons.math.optimization.RealPointValuePair,java.lang.String)>($r6, r0, r1, $r7, 1.0E-12, 1.0E-6, 2000, i1, r4, $r8)
254- : i1 = i1 + 1
254- : goto [?= (branch)]
262- : return

As you can see, two IR codes are different and I'm not sure what is wrong here. I just used two different versions of defects4j and my code for instrumentation is completely the same. Also, I didn't face such a problem in other programs except for Math 38.

SaraBaradaran avatar Apr 24 '25 01:04 SaraBaradaran

Hi @SaraBaradaran,

Defects4J v2 and v3 use different Java versions to compile the artifacts, which probably explains the difference in the IR (explicit use of StringBuilder vs. dynamic invoke for string concatenation).

Is this a problem with the instrumentation, or do you observe a different test behavior (different assertion failures and/or stack traces) when running the failing test(s)?

Best, René

rjust avatar Oct 01 '25 08:10 rjust