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

Bug 508

Summary: Stack overflow with sqrt of an expression which returns a double (a 1x1 return type)
Product: Eigen Reporter: Tom <tom>
Component: Core - expression templatesAssignee: Nobody <eigen.nobody>
Status: RESOLVED DUPLICATE    
Severity: minor CC: gael.guennebaud, jacob.benoit.1, jitseniesen
Priority: Normal    
Version: 3.1   
Hardware: All   
OS: Windows   
Whiteboard:
Bug Depends on:    
Bug Blocks: 387    

Description Tom 2012-09-05 03:58:16 UTC
int main(int argc, char* argv[])
{
    Eigen::Vector2d v(1.0,2.0);
    double d = sqrt(v.transpose() * v);
}

This triggers an infinite recursion/stack overflow when sqrt and sqrt_default_impl call each other.

Easy to work around--e.g. sqrt(v.dot(v));

Copied from the call stack:

>	Eigen::internal::sqrt_default_impl<Eigen::GeneralProduct<Eigen::Transpose<Eigen::Matrix<double,2,1,0,2,1> >,Eigen::Matrix<double,2,1,0,2,1>,3>,0>::run(const Eigen::GeneralProduct<Eigen::Transpose<Eigen::Matrix<double,2,1,0,2,1> >,Eigen::Matrix<double,2,1,0,2,1>,3> & x)  Line 417 + 0xa bytes	C++

 	Eigen::internal::sqrt<Eigen::GeneralProduct<Eigen::Transpose<Eigen::Matrix<double,2,1,0,2,1> >,Eigen::Matrix<double,2,1,0,2,1>,3> >(const Eigen::GeneralProduct<Eigen::Transpose<Eigen::Matrix<double,2,1,0,2,1> >,Eigen::Matrix<double,2,1,0,2,1>,3> & x)  Line 447 + 0xf bytes	C++
Comment 1 Jitse Niesen 2012-09-05 18:41:47 UTC
I've no time at the moment to investigate, but this is probably the same issue as bug 314. However, it is more urgent to fix now that it's more than a theoretical problem.
Comment 2 Gael Guennebaud 2012-10-09 13:49:26 UTC
That's indeed the same issue.

*** This bug has been marked as a duplicate of bug 314 ***
Comment 3 Nobody 2019-12-04 11:52:30 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/508.