This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 993

Summary: Stack overflow when passing matrix inverse as function argument
Product: Eigen Reporter: Sergiu Deitsch <sergiu.deitsch>
Component: LUAssignee: Nobody <eigen.nobody>
Status: RESOLVED FIXED    
Severity: Crash CC: chtz
Priority: Highest    
Version: 3.2   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Test case none

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
Fixed:
https://bitbucket.org/eigen/eigen/commits/510021a
Comment 4 Sergiu Deitsch 2015-04-09 23:54:40 UTC
Great. Thanks!
Comment 5 Nobody 2019-12-04 14:28:58 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/993.