This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1341 - The following code segfaults on Mac OSx but not Linux
Summary: The following code segfaults on Mac OSx but not Linux
Status: CONFIRMED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Tensor (show other bugs)
Version: unspecified
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-15 21:10 UTC by cshay42
Modified: 2019-12-04 16:30 UTC (History)
4 users (show)



Attachments

Description cshay42 2016-11-15 21:10:23 UTC
From Marcos.h:

#define EIGEN_WORLD_VERSION 3
#define EIGEN_MAJOR_VERSION 2
#define EIGEN_MINOR_VERSION 94



The following code segfaults on Mac OSx:

#include <Eigen/Core>
#include <unsupported/Eigen/CXX11/Tensor>
#include <iostream>
#include <array>

using namespace Eigen;
using namespace std;


int main()
{
        Eigen::Tensor<double, 1> tensor(5);
        Eigen::Tensor<double, 1> tensor2(5);

        tensor.setConstant(1);
        tensor2.setConstant(2);
        tensor(1) = 1;
        tensor2(1) = 2;

        std::array<Eigen::IndexPair<int>, 1> product_dims = { IndexPair<int>(0, 0) };

        Eigen::Tensor<double, 1> tensor3(1);

        tensor3.setConstant(0);

        auto v = tensor.contract(tensor2, product_dims);

        cerr<<v<<endl;

        tensor3 = v;

        cerr<<tensor3<<endl;
}


it doesn't reach the second print command, and segfaults on tensor3 = v.

On Linux it works fine (prints 10 twice).

The version of g++ it segfaults on:

g++ (GCC) 5.0.0 20141005 (experimental)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



Command used to compile:

g++ 1.cpp -std=c++0x -I/eigenpath/eigen


If you have any hints how to overcome this on Mac OSx with that g++ version it will be greatly appreciated.
Comment 1 Gael Guennebaud 2016-11-18 11:38:10 UTC
I'm not expert of the Tensor module, but I think you have to use tensor of dimension 0 for tensor3:

Eigen::Tensor<double, 0> tensor3;

Nonetheless, this needs to be clarified. Either by triggering a static assertion or by allowing tensor of dim 1 for that.
Comment 2 Nobody 2019-12-04 16:30:17 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/1341.

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