Skip to content
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

Crashes on Ubuntu 24 when using minimum C++17 and expecting Eigen to not require explicit alignment anymore #6126

Open
StefanFabian opened this issue Sep 6, 2024 · 3 comments
Labels
kind: bug Type of issue status: triage Labels incomplete

Comments

@StefanFabian
Copy link

Context

Since C++17 Eigen does not require custom alignment handling anymore.
Since ROS 2 Humble, C++17 has been the default, and at this time, support can be expected for new software.

Expected behavior

To be able to use Eigen without using the macros to create custom alignment for structs such as EIGEN_MAKE_ALIGNED_OPERATOR_NEW.

Current Behavior

This will crash because #5793 disabled the automatic Eigen check to disable the need for custom-aligned allocation.
This results in the destructors of classes/structs containing Eigen members but not the EIGEN_MAKE_ALIGNED_OPERATOR_NEW macro (which is not needed for >=C++17) crashing when trying to free the memory.
E.g. with a

free(): invalid next size (normal)                                                                                          
Aborted (core dumped)

This is especially annoying since fixing this on the user side would require adding the macro in every class that directly or by inheritance contains eigen members and using the custom stl container allocators for any such class.
A practice that is cumbersome and error-prone.

Your Environment (please complete the following information):

  • OS: Ubuntu 24
  • Compiler: [:eg GCC 8.1]
  • PCL Version libpcl-dev (1.14)

Possible Solution

Setting the CXX standard to 17 (in general or for releases >=Ubuntu 22)

@StefanFabian StefanFabian added kind: bug Type of issue status: triage Labels incomplete labels Sep 6, 2024
@larshg
Copy link
Contributor

larshg commented Sep 6, 2024

Its because you want to use apt installed PCL, which I assume is build with c++14, in a c++17 project, that you encounter the error?
As an alternative you can just compile PCL from source with c++17 enabled? Then its not added according to #5793?

@StefanFabian
Copy link
Author

Yes, I use an apt-installed PCL.
The problem with compiling from source is that apt updates would probably overwrite a global installation, and I can't uninstall the apt package because other packages depend on it.
And especially when using it in a plugin, this would just be asking for trouble.

@mvieth
Copy link
Member

mvieth commented Sep 8, 2024

One thing you can try is making use of PCL_NO_PRECOMPILE: https://pcl.readthedocs.io/projects/tutorials/en/master/adding_custom_ptype.html#how-to-add-a-new-pointt-type The effect is that PCL's templated classes will be compiled together with your own code, with the same settings. Whether this fixes the problem also depends on what you use from PCL.

This is especially annoying since fixing this on the user side would require adding the macro in every class that directly or by inheritance contains eigen members and using the custom stl container allocators for any such class.
A practice that is cumbersome and error-prone.

Out of interest, how many classes would this be? Are these classes that use Eigen, but are unrelated to PCL?

The problem with compiling from source is that apt updates would probably overwrite a global installation

The PCL apt packages for a specific Ubuntu release will very likely not receive any update, at least this was, to my knowledge, never the case in the past. So on Ubuntu 24.04, you will e.g. not get PCL 1.15 (which is not yet released anyway), as a Ubuntu release keeps the software versions fixed, and only applies important security fixes for some packages (as far as I know).
If you build PCL from source, it will by the way be installed in a different location (/usr/local) than the apt version, at least by default.

And especially when using it in a plugin, this would just be asking for trouble.

Not sure what you mean? What kind of plugin?

Setting the CXX standard to 17 (in general

I am willing to discuss such a change, but since you will not get a different PCL version via apt on Ubuntu 24.04, this would be irrelevant for you.
By the way, we, the PCL maintainers, are not directly responsible for the apt packages and which setting are used while building PCL for the packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Type of issue status: triage Labels incomplete
Projects
None yet
Development

No branches or pull requests

3 participants