New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1411 - Quaternion product crashes if EIGEN_DONT_ALIGN_STATICALLY is defined
Quaternion product crashes if EIGEN_DONT_ALIGN_STATICALLY is defined
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Geometry
3.4 (development)
x86 - SSE All
: High Crash
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-03-28 03:50 UTC by Shuntaro Yamazaki
Modified: 2017-06-07 08:12 UTC (History)
4 users (show)



Attachments
Patch (1.62 KB, patch)
2017-03-28 03:50 UTC, Shuntaro Yamazaki
no flags Details | Diff

Description Shuntaro Yamazaki 2017-03-28 03:50:51 UTC
Created attachment 783 [details]
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
Comment 1 Shuntaro Yamazaki 2017-05-09 13:02:59 UTC
Can anyone take a look at this report?
Comment 2 Shuntaro Yamazaki 2017-05-09 13:03:20 UTC
Can anyone take a look at this report?
Comment 3 Gael Guennebaud 2017-06-07 08:12:19 UTC
Thank you for the report and patch that I adapted to be more general:

https://bitbucket.org/eigen/eigen/commits/ecca45864eb6 (devel)
https://bitbucket.org/eigen/eigen/commits/19554c1ac9a5 (3.3)

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