SparseLU::factorize crashes with error: "Assertion `index >= 0 && index < size()' failed."
Submitted by ren..@..mu.edu
Assigned to Nobody
Link to original bugzilla bug (#792)
Version: 3.2
Operating system: Linux
Description
Created attachment 451
program illustrating the problem
Compile and run the attached program, which constructs a 10 x 10 sparse matrix and then attempts to compute an LU factorization. It prints out:
Nonzero entries:
(1,1) (-1,1)
Outer pointers:
0 0 1 1 2 2 2 2 2 2 $
0 0 0 0 0 0 0 0 0 0
0 1 0 -1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
a.out: eigen/Eigen/src/Core/DenseCoeffsBase.h:412: Scalar &Eigen::DenseCoeffsBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>, 1>::operator()(Index) [Derived = Eigen::Matrix<int, -1, 1, 0, -1, 1>, Level = 1]: Assertion `index >= 0 && index < size()' failed.
According to gdb, the value of index at the time of failure is 6684880.
The problem can be traced to the pivotL() function in SparseLU_pivotL.h. The lsub_ptr variable points to uninitialized memory. We detect that the matrix is singular, and then we try to lookup perm_r(pivrow), where pivrow is read from the uninitialized memory. Line 90:
if ( pivmax == 0.0 ) {
pivrow = lsub_ptr[pivptr];
perm_r(pivrow) = jcol;
return (jcol+1);
}
This behavior is present in revision 5877:cd6ffdff46d2d3b9de945d81e20604c9648b83a1.
Attachment 451, "program illustrating the problem":
bug133.cpp