-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eigen Alignment #653
Comments
@morrisfranken any suggestions for us to solve this issue? |
I see it in #654 . |
@morrisfranken I tried on a few Ubuntus and still cannot reproduce the error? Can you help us reproduce the error? Maybe package a docker container with the exact environment you have so we can exactly reproduce it. @takanokage can help you set up a docker if you are not familiar with it. |
I will be able to create a docker this weekend, but can you confirm that the following code runs fine on your machine?
For me it produces the following output:
|
I confirm that the issue is reproducible with the above test. The fix for the above test, as suggested in #654 is to replace |
However I'd also like to point out that the issue is not reproducible if instead of |
I might be mistaken but in the past not allocating aligned memory has led to performance issues only and not errors/crashes. @morrisfranken Could you please tell us more about what you were working on when you encountered this error? I've search the whole Open3D and |
@morrisfranken another question: where you able to reproduce the issue without |
This is the code I used:
Uncomment one section at a time (v1/v2/v3) in order to build/run the code. |
These are a few more cases in which is segfaults for me without
I'm however not an expert on Eigen and don't know exactly why it produces a segfault in the examples above. But it seems we are entering the realm of undefined behaviour, and even if it does not produce a segfault right away,- it may appear later in the program out of nowhere. The Eigen documentation does not indicate the consequences of not using the allocator, but they are clear on that you have to use it (in my case, even causing the program to crash due to an assert):
To answer your question earlier, I was mainly working with |
Using STL Containers with Eigen According to the documentation found at the above link:
|
It would appear that we really need to make the change. |
Eigen::Matrix4d is such a type among others
|
Well, all this said I'm not sure we really need to make this change everywhere in Open3D. |
* Eigen alignment support * remove white spacing * Fixing mac-build by adding const * Removing Eigen alignment for types that do not require it. Removing the `EIGEN_MAKE_ALIGNED_OPERATOR_NEW` from classes, and replace Eigen types within classes with their unaligned counterpart where required. This will prevent segfaults due to different compiler flags used for Open3D and a library that depends on it. (#653) * Eigen alignment for merge with IntelVCL/Open3D Removing alignment from `pybind_eigen_vector_of_vector` since it is conflicting with pybind and because none of the templated types require alignment. * Trimming whitespace and added functions `EigenMatrix4dToJsonArray` and `EigenMatrix6dToJsonArray` with unaligned support * Update for merging with original repo * reduced line width to 80 cols or less. * added unit tests for testing the conversion of unaligned Eigen::Matrix4d/6d to and from JsonArray. added unit tests comments. * fix path. * match master gitmodules. * test fix submodule issue that was breaking the build.
It should be not that Lines 293 to 295 in a5be78c
It is reported in Eigen's doc that C++ 17 or later version can take care of alligned_allocator well through compilation. |
Hi, I've been experiencing a number of random segfaults while executing functions like
RegistrationColoredICP
andWritePoseGraph
. After debugging a bit, it turns out that these segfaults are coming from incorrect use of Eigen structures. For example, the following code will produce a segfault (compiled in release with gcc5.4 on Ubuntu 16.04, Intel I7-4712MQ)Similar to what #88 has found, Eigen structures required a custom allocator when being used in containers like
std::vector
orstd::map
(https://eigen.tuxfamily.org/dox/group__TopicStlContainers.html) . In addition,- when defining Eigen variables within a class, these classes must be aligned as well (https://eigen.tuxfamily.org/dox/group__TopicStructHavingEigenMembers.html)To solve these issues I've created a new fork of Open3D with Eigen Alignment Support: https://github.com/morrisfranken/Open3D . While I can confirm that this branch resolves the segfaults that I was experiencing before, it may break other peoples code.
More over- the Eigen alignment issue stretches beyond simple segfaults within the library. By exposing the Open3D API with Eigen elements, it requires all libraries that use Open3D to be compiled with the same optimisation options as Open3D itself. Otherwise the sizes (in bytes) of Open3D classes may differ compared to a library that is using Open3D. For example,- suppose the following class is exposed in a header of Open3D:
The size of this class will vary based on the compiler flags used:
When compiling Open3D with its default settings, the library expects the size of
PoseGraphNode
to be 144. But when I compile an executable that depends on Open3D with the flag-march=native
, and I call the functioncompute(node)
, that executable will pass 160 bytes to the function where Open3D only expects 144 which causes undefined behaviour and most likely segfault somewhere down the line.At this moment I don't see any other way to prevent this behaviour entirely other than disabeling alignment in exposed structs by using
Eigen::DontAlign
.The text was updated successfully, but these errors were encountered: