Skip to content

Segfault with LAPACKE SVD backend

Hello,

I need an SVD of a large complex matrix. I was hoping to use the Intel MKL back-end to exploit their multi-threaded version. However, I am getting a segfault when enabling the LAPACKE backend for Eigen. I also tried calling the cgesvd function manually (passing in the Eigen matrices via the .data() member function) and the same thing happened. Any idea why this is happening?

Platform: macOS 10.15.4 Compiler: Latest Apple Clang Eigen version: master MKL version: 2019.4.233

The following small program should generate the error (based on https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_cgesvd_col.c.htm)

#define EIGEN_USE_LAPACKE
#include <Eigen/SVD>
#include <iostream>

/* Main program */
int main()
{
  long const M = 3;
  long const N = 4;
  Eigen::MatrixXcf a(M, N);
  a << std::complex<float>{5.91f, -5.69f}, std::complex<float>{-3.15f, -4.08f},
      std::complex<float>{-4.89f, 4.20f}, std::complex<float>{7.09f, 2.72f},
      std::complex<float>{-1.89f, 3.27f}, std::complex<float>{4.10f, -6.70f},
      std::complex<float>{7.78f, -4.06f}, std::complex<float>{4.57f, -2.07f},
      std::complex<float>{3.28f, -3.84f}, std::complex<float>{-0.79f, -7.21f},
      std::complex<float>{-3.88f, -3.30f}, std::complex<float>{3.84f, 1.19f};

  Eigen::JacobiSVD<Eigen::MatrixXcf> svd(a, Eigen::ComputeThinU | Eigen::ComputeThinV);
  std::cout << svd.singularValues() << '\n';
}

If you comment out the #define at the top, it runs fine. With LAPACKE enabled, Address Sanitizer gives the following output:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==16979==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x000104cc63a5 bp 0x000000000053 sp 0x7ffeeaf489f8 T0)
==16979==The signal is caused by a READ memory access.
==16979==Hint: this fault was caused by a dereference of a high value address (see registers below).  Dissassemble the provided pc to learn which register value was used.
    #0 0x104cc63a4 in LAPACKE_cge_nancheck (demo_lapack:x86_64+0x1000103a4)

==16979==Register values:
rax = 0x0000000000000001  rbx = 0x0000000000000066  rcx = 0x0004607000000538  rdx = 0x0000000000000004  
rdi = 0x0004607000000538  rsi = 0x0000000000000003  rbp = 0x0000000000000053  rsp = 0x00007ffeeaf489f8  
 r8 = 0x00007ffe00000003   r9 = 0x0000000000000000  r10 = 0x00007ffeeaf491c0  r11 = 0x00007fff7340255f  
r12 = 0x0000000000000053  r13 = 0x0000000000000003  r14 = 0x0000000000000004  r15 = 0x0000608000000520  
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (demo_lapack:x86_64+0x1000103a4) in LAPACKE_cge_nancheck
==16979==ABORTING