This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 527 - Crash in ConjugateGradient::solve() when expression is given.
Summary: Crash in ConjugateGradient::solve() when expression is given.
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.1
Hardware: x86 - 64-bit Windows
: Normal major
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-24 09:00 UTC by Vladimir
Modified: 2019-12-04 11:57 UTC (History)
0 users



Attachments
callstack1 (8.99 KB, text/plain)
2012-10-24 09:00 UTC, Vladimir
no flags Details
callstack 2 (8.08 KB, text/plain)
2012-10-24 09:00 UTC, Vladimir
no flags Details

Description Vladimir 2012-10-24 09:00:18 UTC
Created attachment 304 [details]
callstack1

Here is the code snippet (part of the function body):


void solve(const VectorXd& initial_alpha) {
  typedef Eigen::SparseMatrix<double, Eigen::RowMajor> SparseMatrixType;
  typedef Eigen::Triplet<double> DoubleTriplet; 

  SparseMatrixType laplacian;
  fill_laplacian(laplacian); 
/* laplacian's size is 2450x2450, it is symmetric, positive definite */

  SparseMatrixType D(laplacian.rows(), laplacian.cols());
  vector<DoubleTriplet> D_triplets;
  const double lambda = 0.1;

  for(int i = 0; i < laplacian.rows(); ++i) {
    double value = /* calculated value */;
    D_triplets.push_back(DoubleTriplet(i, i, value));
  }

  D.setFromTriplets(D_triplets.begin(), D_triplets.end());

  VectorXd b = ;

  ConjugateGradient<SparseMatrixType, Upper> cg;
  cg.setTolerance(1e-15);
  cg.setMaxIterations(500);

  cg.compute(laplacian + lambda * D); 
  VectorXd alpha = cg.solve(lambda * D * initial_alpha); // <- crash
}

I've observed 2 types of crashes.

1. When both cg.compute() and cg.solve() are called with expressions, visual studio gives Access violation reading location <some address>.

Crash is in the file Eigen/src/SparseCore/SparseMatrix.h, line 950, method
SparseMatrix<Scalar,_Options,_Index>::InnerIterator::index()

m_id = -544149818

Call stack is in the attached file callstack1.txt 

2. If I replace an argument of solve() with pre-calculated variable:

    VectorXd b = lambda * D * initial_alpha;
    cg.compute(laplacian + lambda * D); 
    VectorXd alpha = cg.solve(lambda * D * initial_alpha); // <- crash

then I've got failed Eigen assertion:

Assertion failed: 
(i>=0) && 
(
 ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && i<xpr.rows()) ||
 ((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && i<xpr.cols())
), file c:\eigen\eigen\src/Core/Block.h, line 280

here i = 1007402692;
xpr.rows() return 2450, xpr.cols() returns 1.
Call stack is in the attached file callstack2.txt


3. If I replace an argument of cg.compute() with precalculated variable, everything works fine:

  SparseMatrixType A = laplacian + lambda * D;
  cg.compute(A);
  alpha = cg.solve(lambda * D * initial_alpha);

I can attach text files with concrete matrices, if needed.
Comment 1 Vladimir 2012-10-24 09:00:47 UTC
Created attachment 305 [details]
callstack 2
Comment 2 Vladimir 2012-10-24 09:02:59 UTC
Sorry, code for the 2nd crash should read like the following

2. If I replace an argument of solve() with pre-calculated variable:

    VectorXd b = lambda * D * initial_alpha;
    cg.compute(laplacian + lambda * D); 
    VectorXd alpha = cg.solve(b); // <- eigen assertion
Comment 3 Nobody 2019-12-04 11:57:23 UTC
-- 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/527.

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