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 447 - seg fault on (A * B)(0, 0)
Summary: seg fault on (A * B)(0, 0)
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - matrix products (show other bugs)
Version: 3.0
Hardware: x86 - 64-bit Linux
: Normal Unknown
Assignee: Nobody
Depends on:
Reported: 2012-04-13 00:27 UTC by Bowie Owens
Modified: 2012-04-18 18:48 UTC (History)
2 users (show)


Description Bowie Owens 2012-04-13 00:27:08 UTC
When I multiply two matrices and index into the product (without saving it to a matrix variable) I get a segmentation fault. The following program reproduces the problem for me. Note it seems to be some sort of infinite recursion.

#include <Eigen/Dense>

    Eigen::MatrixXd A (1, 3);
    A << 1, 2, 3;

    Eigen::MatrixXd B (3, 1);
    B << 4, 5, 6;

    double p = (A * B)(0, 0);

    return 0;

I am using x86-64 Linux and GCC 4.6.2 with Eigen 3.0.5.
Comment 1 Jitse Niesen 2012-04-18 16:28:39 UTC
Thanks for the report. This is indeed an infinite recursion in ProductBase::coeff(), triggered by a product of dynamic-size matrices. Note that you can only index into a product if the result has size 1-by-1. This bug has been bresent for a while.

One possible fix is to restrict indexing for *fixed-size* products of size 1-by-1. But this gives a difference between fixed and dynamic size which seems unnecessary. I implemented another fix and added a regression test (changeset 2bba8cc484ad for Eigen 3.0 and 0c2dd64f0b25 for Eigen 3.1)
Comment 2 Gael Guennebaud 2012-04-18 18:48:37 UTC
Thanks Jitse for fixing it.

To Bowie, since you know that A and B are vectors, you should really use vectors: huge speed up expected.

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