There are 4 known causes for this issue. Please read on to understand them and learn how to fix them.

Where in my own code is the cause of the problem?

First of all, you need to find out where in your own code this assertion was triggered from. At first glance, the error message doesn't look helpful, as it refers to a file inside Eigen! However, since your program crashed, if you can reproduce the crash, you can get a backtrace using any debugger. For example, if you're using GCC, you can use the GDB debugger as follows:

$ gdb ./my_program # Start GDB on your program

> run # Start running your program

... # Now reproduce the crash!

> bt # Obtain the backtrace

Now that you know precisely where in your own code the problem is happening, read on to understand what you need to change.

The same issue will be exhibited by any classes/functions by-passing operator new to allocate memory, that is, by performing custom memory allocation followed by calls to the placement new operator. This is for instance typically the case of std::make_shared or std::allocate_shared for which is the solution is to use an aligned allocator as detailed in the solution for STL containers.

Cause 3: Passing Eigen objects by value

If some function in your code is getting an Eigen object passed by value, like this,

General explanation of this assertion

Eigen normally takes care of these alignment issues for you, by setting an alignment attribute on them and by overloading their "operator new".

However there are a few corner cases where these alignment settings get overridden: they are the possible causes for this assertion.

I don't care about optimal vectorization, how do I get rid of that stuff?

Three possibilities:

Use the DontAlign option to Matrix, Array, Quaternion, etc. objects that gives you trouble. This way Eigen won't try to align them, and thus won"t assume any special alignment. On the down side, you will pay the cost of unaligned loads/stores for them, but on modern CPUs, the overhead is either null or marginal. See here for an example.

Define EIGEN_DONT_ALIGN_STATICALLY . That disables all 16-byte (and above) static alignment code, while keeping 16-byte (or above) heap alignment. This has the effect of vectorizing fixed-size objects (like Matrix4d) through unaligned stores (as controlled by EIGEN_UNALIGNED_VECTORIZE ), while keeping unchanged the vectorization of dynamic-size objects (like MatrixXd). But do note that this breaks ABI compatibility with the default behavior of static alignment.

Or define both EIGEN_DONT_VECTORIZE and EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT. This keeps the 16-byte alignment code and thus preserves ABI compatibility, but completely disables vectorization.

If you want to know why defining EIGEN_DONT_VECTORIZE does not by itself disable 16-byte alignment and the assertion, here's the explanation:

It doesn't disable the assertion, because otherwise code that runs fine without vectorization would suddenly crash when enabling vectorization. It doesn't disable 16-byte alignment, because that would mean that vectorized and non-vectorized code are not mutually ABI-compatible. This ABI compatibility is very important, even for people who develop only an in-house application, as for instance one may want to have in the same application a vectorized path and a non-vectorized path.