This bugzilla service is closed. All entries have been migrated to
Bug 1423 - LeastSquaresConjugateGradient does handle row-major sparse matrices properly
Summary: LeastSquaresConjugateGradient does handle row-major sparse matrices properly
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Crash
Assignee: Nobody
Depends on:
Reported: 2017-04-25 22:52 UTC by Bailin Deng
Modified: 2019-12-04 16:58 UTC (History)
2 users (show)

Codes that reproduce the error. (1.43 KB, text/x-csrc)
2017-04-25 22:52 UTC, Bailin Deng
no flags Details

Description Bailin Deng 2017-04-25 22:52:50 UTC
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
      for(Index j=0; j<mat.outerSize(); ++j)
        RealScalar sum = mat.innerVector(j).squaredNorm();
          m_invdiag(j) = RealScalar(1)/sum;
          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.
Comment 1 Gael Guennebaud 2017-06-08 13:07:22 UTC
Thank you for the report, fixed: (devel) (3.3)
Comment 2 Nobody 2019-12-04 16:58:23 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to'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:

Note You need to log in before you can comment on or make changes to this bug.