Bug 410 - EigenSolver::eigenvectors() crashes when solving matrix with infinity (-1.#IND) in it
: EigenSolver::eigenvectors() crashes when solving matrix with infinity (-1.#IN...
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Eigenvalues
: 3.1
: All All
: Normal normal
Assigned To: Nobody
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2012-01-23 07:12 UTC by Alex Melkozerov
Modified: 2012-01-25 19:05 UTC (History)
4 users (show)



Attachments

Description Alex Melkozerov 2012-01-23 07:12:17 UTC
Eigenvalues module crashes in release (or emits debug error in Debug mode) if
one passes to Eigen::EigenSolver a 1x1 matrix with 1 indefinite element in it.
A simple program to reproduce bug:

#include <Eigen/Eigenvalues>
typedef Eigen::MatrixXd EigenMatrix;

int main() {

    EigenMatrix A(1,1);
    A(0,0) = std::sqrt(-1.);
    Eigen::EigenSolver<EigenMatrix> solver(A);
    EigenMatrix V(1, 1);
    V(0,0) = solver.eigenvectors()(0,0).real();
    return 0;
}

The problem is in line 342 of EigenSolver.h
(https://bitbucket.org/eigen/eigen/src/ec430a9cb055/Eigen/src/Eigenvalues/EigenSolver.h#cl-342):
internal::isMuchSmallerThan() check returns false, and line 357
matV.col(j+1).normalize();
is executed although matV contains just 1 column. This causes assertion failure
in debug and crashes program in release.

Quick and dirty fix: add to line 342 second condition: || n == 1.
Comment 1 Gael Guennebaud 2012-01-25 19:05:09 UTC
Thanks for the analyze of the error, though I rather added:

|| j+1==n


Fixed there:

https://bitbucket.org/eigen/eigen/changeset/d2189ba9dfd1/
changeset:   d2189ba9dfd1
date:        2012-01-25 19:02:31
summary:     fix bug 410: fix a possible out of range access in EigenSolver

https://bitbucket.org/eigen/eigen/changeset/b8c6abb0d78a/
changeset:   b8c6abb0d78a
branch:      3.0

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