Bugzilla – Bug 222
jacobisvd_7 unit test hits data-not-aligned assertion when EIGEN_DEFAULT_TO_ROW_MAJOR is defined
Last modified: 2014-03-26 17:52:31 UTC
Created attachment 140 [details]
Minimal test example
On my computer (gcc 4.3, 32 bits) the jacobisvd_7 unit test fails on a data-not-aligned assertion if compiling the tests in Release mode with SSE2 enabled and EIGEN_DEFAULT_TO_ROW_MAJOR defined.
Side note: Probably not serious enough to delay RC1 for.
See http://eigen.tuxfamily.org/CDash/testDetails.php?test=266017&build=5472 for the precise message.
I did not yet have time to analyze it fully, but here are some results.
I boiled down the test to the attached minimal test example. Compile with -msse2 -O2 and run to trigger the failure. The #define EIGEN_STACK_ALLOCATION_LIMIT 0 is copied from the jacobisvd_7 test and necessary to trigger the bug. The size of 49 is the smallest size for which it goes wrong. The significance of the number is probably that it is one more than 48, the block size for the Householder.
I'll also attach a stack trace shortly. The assertion is triggered in Product.h:442 because actualDestPtr is not aligned. This pointer is defined in Product.h:434. At that point, dest.size() is 0, so ei_aligned_stack_new() calls alloca(). However, alloca(0) does not return an aligned pointer.
Created attachment 141 [details]
Backtrace produced by GDB
I guess this has long been fixed.
I can still reproduce the bug with the current dev version and GCC 4.8.2 (in CMake, set EIGEN_TEST_32BIT to ON and EIGEN_TEST_CUSTOM_CXX_FLAGS to -DEIGEN_DEFAULT_TO_ROW_MAJOR).
Sorry for closing this, prematurely. I actually only tested EIGEN_DEFAULT_TO_ROW_MAJOR on a 64bit platform, but never on 32bit.
I can reproduce the error with g++ 4.7.1 on Linux 32bit, but strangely not if compiling your reduced example with -O0.
Generally, the jacobisvd implementations looks inefficient for with EDTRM, because it allocates a Matrix<Scalar, 48, 48> and accesses that column-by-column.
I worked around the issue, by forcing the internal temporary matrix to be column-major:
Actually, it would still be interesting to find the actual cause of the error.