I run into the following problem all the time recently:
- I have a large-ish codebase which uses Eigen and PCL (which also uses Eigen)
- I need to use the almost current Eigen master branch and can't use a stable release due to a dependency requiring it.
- Both PCL and other dependencies in my project make use of vector instructions, so I compile with
-march=native. - When running some things that involve Eigen types (Affine transforms, Point cloud viewing), I sometimes get segmentation faults or other crashes in seemingly nonsensical locations, such as in the
Eigen::Quaternionfconstructor. In other case, theEIGEN_UNALIGNED_ASSERTis triggered, which leads one to this page, whose contents I observe everywhere in my code (so far as I know)
I want to be a good citizen so I try to reproduce the problem on a minimal example to post on stackoverflow or in the related issue trackers. However I invariably fail at reproducing the crash when extracting just the bit triggering the problem. My guess is that whether or not memory is aligned (and no special care is taken) is also dependent on what was allocated before the problem location, so the surrounding code is instrumental in triggering the issue.
Question: What techniques and tools can I use to effectively determine the source of memory-alignment-related crashes in C+14 on Linux and/or macOS?