Created attachment 786 [details] Codes that reproduce the error. When using LeastSquaresConjugateGradient for row-major sparse matrices with more rows than columns, Eigen crashes at the following function in Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h: LeastSquareDiagonalPreconditioner& factorize(const MatType& mat) { // Compute the inverse squared-norm of each column of mat m_invdiag.resize(mat.cols()); for(Index j=0; j<mat.outerSize(); ++j) { RealScalar sum = mat.innerVector(j).squaredNorm(); if(sum>0) m_invdiag(j) = RealScalar(1)/sum; else m_invdiag(j) = RealScalar(1); } Base::m_isInitialized = true; return *this; } Here the dimension of m_invdiag is the number of columns, but mat.outerSize() is the number of rows, resulting in out-of-bound access of m_invdiag in the loop.
Thank you for the report, fixed: https://bitbucket.org/eigen/eigen/commits/45a5c5dde931/ (devel) https://bitbucket.org/eigen/eigen/commits/9688211a9ef2/ (3.3)
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1423.