55 seconds ago

Commons Math is a library of lightweight, self-contained mathematics and statistics components addressing the most common problems not available in the Java programming language or Commons Lang.


Issue 1005: https://issues.apache.org/jira/browse/MATH-1005

get ArrayIndexOutOfBoundsException in MathArrays.linearCombination when passing argument with length = 1

Test case:

Analyzed Result

26 seconds ago

Result from Ziyuan:

org.apache.commons.math3.util.MathArrays:581 (debugLine: 582)
suspiciousness: 0.89
Logic: a.length >= 2.0
Accuracy: 1

org.apache.commons.math3.util.MathArrays:586 (debugLine: 588)
suspiciousness: 0.89
Logic: len >= 2.0
Accuracy: 1

org.apache.commons.math3.util.MathArrays:589 (debugLine: 591)
suspiciousness: 0.89
Logic: len >= 2.0
Accuracy: 1

The following predicate is output

org.apache.commons.math3.util.MathArrays:586 (debugLine: 588)
Logic: len >= 2.0


14 seconds ago

Ziyuan's result suggests that in this case, if the length of the input is larger than 1, no error occurs. The actual fix for this issue as in the bug report is as follows: linearCombination should check the length of the arguments and fall back to simple multiplication if length == 1. It means that what Ziyuan finds out is indeed an invariant (part of the precondition) of the method.


We feed the passed test cases from Ziyuan to Daikon. After a while, Daikon throws an exception as below:

[2:08:54 PM]: Finished reading ./DaikonTestIssue1005.dtrace.gz


LTCore: vals NaN 0.45374770890405647 0.45374770890405647

LTCore: vals NaN 0.5913778990017722 0.5913778990017722

LTCore: vals NaN 0.35379204277105525 0.35379204277105525

LTCore: vals NaN 0.9346384456263126 0.9346384456263126

LTCore: vals NaN 0.9346384456263126 0.9346384456263126

LTCore: vals NaN 0.35379204277105525 0.35379204277105525

in inv warning: too few saEmplxecse pftoiro nd aiink otnh.rienavd. t"emrnarayi.nt"hree Scalar.LinearTernaryFloat invariant: (this.nextGaussian, return, return) daikon.PptSlice3: org.apache.commons.math3.random.BitsStreamGenerator.nextDouble():::EXIT87 this.nextGaussian return return samples: 60000


at daikon.inv.ternary.threeScalar.LinearTernaryCoreFloat.setup(LinearTernaryCoreFloat.java:291)

at daikon.inv.ternary.threeScalar.LinearTernaryFloat.setup(LinearTernaryFloat.java:293)

at daikon.DynamicConstants.instantiate_constant_suppressions(DynamicConstants.java:784)

at daikon.DynamicConstants.instantiate_new_views(DynamicConstants.java:489)

at daikon.DynamicConstants.post_process(DynamicConstants.java:937)

at daikon.Daikon.process_data(Daikon.java:1946)

at daikon.Daikon.mainHelper(Daikon.java:573)

at daikon.Daikon.main(Daikon.java:453)


The input of FailureDoc is a sequence. In this case, we manually create below sequence as its input. However, FailureDoc says that the sequence has not error and does not give any explanation.


var0 = prim : double:1.23456789 :

var1 = prim : double:98765432.1 :

var2 = array : double[1] : var0

var3 = array : double[1] : var1

var4 = method : org.apache.commons.math3.util.MathArrays.linearCombination([double,[double) : var2 var3