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.
Created attachment 305 [details] callstack 2
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
-- 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.