3
votes

I just tried to allocate an instance which contains Eigen::Matrix to Xenomai's shared memory.

unsigned char * mem; //shared memory pointer
Robot * robot = new ((void *)(mem+ROBOT_ADDR)) Robot();

The Robot class contains several Eigen::Matrix. However, I can't allocate robot object in my shared memory.

But the basic allocation was working well lke below.

Robot * robot = new Robot(); //work well!

The Assertion log is:

Eigen::internal::plain_array::plain_array() [with T = double; int Size = 36; int MatrixOrArrayOptions = 0]: Assertion `(reinterpret_cast(eigen_unaligned_array_assert_workaround_gcc47(array)) & 0xf) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"' failed.

I already checked the web page in the log. But there is no solution for my case.

How to do placement allocation Eigen::Matrix to Shared Memory (or user-defined specific heap)?

1

1 Answers

2
votes

As per the linked webpage:

fixed-size vectorizable Eigen objects must absolutely be created at 16-byte-aligned locations, otherwise SIMD instructions addressing them will crash.

So the problem is that mem+ROBOT_ADDR is not 16-byte aligned. You need to ensure that it is.