This bugzilla service is closed. All entries have been migrated to
Bug 1092 - Bicgstab segfault when constructed from sparse matrix expression / temporary.
Summary: Bicgstab segfault when constructed from sparse matrix expression / temporary.
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.2
Hardware: x86 - 64-bit Linux
: Normal Crash
Assignee: Nobody
Depends on:
Reported: 2015-10-18 13:34 UTC by Jure Slak
Modified: 2019-12-04 15:04 UTC (History)
2 users (show)

Source code to reproduce the segfault (minimal working example). (2.02 KB, text/x-c++src)
2015-10-18 13:34 UTC, Jure Slak
no flags Details

Description Jure Slak 2015-10-18 13:34:49 UTC
Created attachment 615 [details]
Source code to reproduce the segfault (minimal working example).

This code segfaults for me:

Eigen::BiCGSTAB<SparseMatrix<double>> BCGST2(ID - dt * shape_laplace);
V2 = BCGST2.solve(V1);  //< this crashes 

where ID and shape_laplace are n by n matrices and dt is a double.
However this:

SparseMatrix<double> tmp = ID - dt * shape_laplace;
Eigen::BiCGSTAB<SparseMatrix<double>> BCGST2(tmp);
V2 = BCGST2.solve(V1);  //< this crashes 

works fine. I read the common pitfalls page and did not find anything to explain such behaviour. Am I missing something trivial or is this a bug?

Before I translated my code to the minimal working example, it sometimes crashed with EIGEN assert: 

./../include/Eigen/src/Core/ProductBase.h:102: Eigen::ProductBase<Derived, Lhs, Rhs>::ProductBase(const Lhs&, const Rhs&) [with Derived = Eigen::SparseTimeDenseProduct<Eigen::SparseMatrix<double, 0, int>, Eigen::Block<Eigen::Matrix<double, -1, 1>, -1, 1, true> >; Lhs = Eigen::SparseMatrix<double, 0, int>; Rhs = Eigen::Block<Eigen::Matrix<double, -1, 1>, -1, 1, true>]: Assertion `a_lhs.cols() == a_rhs.rows() && "invalid matrix product" && "if you wanted a coeff-wise or a dot product use the respective explicit functions"' failed.
Comment 1 Gael Guennebaud 2015-10-26 15:21:23 UTC
Thank you for the report.

Fixed in devel branch (c2aef7f3278b), and 3.2 branch (dd9b4efbd852)
Comment 2 Nobody 2019-12-04 15:04:15 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.