Quaternion product crashes if EIGEN_DONT_ALIGN_STATICALLY is defined
Submitted by Shuntaro Yamazaki
Assigned to Nobody
Link to original bugzilla bug (#1411)
Version: 3.4 (development)
Platform: x86 - SSE
Description
Created attachment 783
Patch
SSE intrinsics can be called with unaligned pointers in quat_product::run, causing SegFault. The same applies to quat_conj::run.
$ cat qprod.cpp
#include <Eigen/Geometry>
int main() {
Eigen::Quaterniond q1 = Eigen::Quaterniond(1,0,0,0);
Eigen::Quaterniond q2 = Eigen::Quaterniond(1,0,0,0);
Eigen::Quaterniond q = q1 * q2;
return q.norm();
}
$ clang++ --version
clang version 3.7.0 (trunk 239477)
Target: x86_64-unknown-linux-gnu
$ clang++ -I. -DEIGEN_DONT_ALIGN_STATICALLY qprod.cpp
$ ./a.out
Segmentation fault
Note that the above code may not cause SegFault if on-stack Quaternion objects happen to be 16-byte aligned.
The issue seems to exist in the latest stable and development branches, and is solved by an attached patch.
Thanks,
Shuntaro
Patch 783, "Patch":
eigen.patch