New user self-registration is disabled due to spam. Please email eigen-core-team @ if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 993 - Stack overflow when passing matrix inverse as function argument
Summary: Stack overflow when passing matrix inverse as function argument
Alias: None
Product: Eigen
Classification: Unclassified
Component: LU (show other bugs)
Version: 3.2
Hardware: All All
: Highest Crash
Assignee: Nobody
Depends on:
Reported: 2015-04-09 16:47 UTC by Sergiu Deitsch
Modified: 2015-04-09 23:54 UTC (History)
1 user (show)

Test case (226 bytes, text/plain)
2015-04-09 16:50 UTC, Sergiu Deitsch
no flags Details

Description Sergiu Deitsch 2015-04-09 16:47:41 UTC
The following code causes a stack overflow in DenseCoeffsBase.h line 212 (as for changeset eac2061f58b1).

> #include <Eigen/Core>
> #include <Eigen/LU>
> template<class Derived>
> void foo(const Eigen::MatrixBase<Derived>& value)
> {
>     Eigen::Matrix2d tmp = value; // boom
> }
> int main()
> {
>     foo(Eigen::Matrix2d::Identity().inverse());
> }

This does not happen, if I call .eval().

I'm using Visual Studio 12 2013.
Comment 1 Sergiu Deitsch 2015-04-09 16:50:32 UTC
Created attachment 562 [details]
Test case
Comment 2 Christoph Hertzberg 2015-04-09 19:23:56 UTC
The problem is that .inverse() returns a ReturnByValue but the initialization above tries to copy the expression packet-wise.
I fixed it locally. I'll commit it after running the testsuite.
Comment 3 Christoph Hertzberg 2015-04-09 20:34:44 UTC
Comment 4 Sergiu Deitsch 2015-04-09 23:54:40 UTC
Great. Thanks!

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