New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 987 - Segmentation fault when multiplying a DiagonalMatrix and a Block
Segmentation fault when multiplying a DiagonalMatrix and a Block
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Core - matrix products
3.2
x86 - SSE Linux
: High Crash
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-03-31 18:31 UTC by Filippo Basso
Modified: 2015-03-31 23:38 UTC (History)
2 users (show)



Attachments

Description Filippo Basso 2015-03-31 18:31:14 UTC
With a simple code like the one below, everything compiles well but I get a segmentation fault on last line:

  Eigen::Matrix3Xd points = Eigen::Matrix3Xd::Zero(3, 2);
  Eigen::DiagonalMatrix<double, 2> diagonal(1, 2);
  Eigen::Matrix2Xd result = diagonal * points.topRows<2>();


I use Eigen 3.2.0 and compile with g++ 4.8.2 on Ubuntu 14.04 64bit.
The segmentation fault happens both in (cmake) Debug and Release modes.
I also tried to enable/disable -std=c++11 but nothing changed. 

The error goes away if the result is not saved, i.e.:

  Eigen::Matrix3Xd points = Eigen::Matrix3Xd::Zero(3, 2);
  Eigen::DiagonalMatrix<double, 2> diagonal(1, 2);
  diagonal * points.topRows<2>();

or if the block operation is saved in a temporary matrix, i.e.:

  Eigen::Matrix3Xd points = Eigen::Matrix3Xd::Zero(3, 2);
  Eigen::DiagonalMatrix<double, 2> diagonal(1, 2);
  Eigen::Matrix2Xd tmp = points.topRows<2>();
  Eigen::Matrix2Xd result = diagonal * tmp;


Looking at the gdb backtrace it seems an SSE-related bug: http://pastebin.com/NqZuVWZ1
Comment 1 Gael Guennebaud 2015-03-31 22:49:42 UTC
Confirmed with bith 3.2 and devel branches. The problem is that Eigen wrongly assumes that the rhs can be read through aligned loads.

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