PCL and GTSAM link error: double free or corruption (out)

578 views
Skip to first unread message

Rakshith Vishwanatha

unread,
Oct 26, 2021, 6:59:57 PM10/26/21
to gtsam users
Hello, 

I have a snippet of code which creates a pcl::RangeImage and processes it. Later in the program, I need to add some nodes to a gtsam graph to denote identified landmarks based on the processing performed on the range image. While I was working on this I got the run time error "double free or corruption (out) Aborted (core dumped)". 

This error was thrown only when gtsam was linked to my code's executable. If gtsam was not linked to my code's executable everything runs fine. 

I have made a very simple test script to reproduce this error here: https://github.com/RakVish1342/gtsam-rangeimage-link-error

Code flow:
  • This script calls a function func() from main(). 
  • In func() a pointcloud with random points is created and a range_image is created from this pointcloud.
  • range_image dimensions are printed and code exists func().
  • Code exits main().
Observations and Issues Noticed:
  • When CMakeLists.txt has "target_link_libraries(linkErr ${PCL_LIBRARIES})" the code works fine.
  • When that line is replaced with "target_link_libraries(linkErr ${PCL_LIBRARIES} gtsam)" the code gets the runtime error.
  • To help with debugging, additional observations are provided as a comment at the end of src/linkErr.cpp file.

For my use case, I can work around this issue by having two separate ros nodes (two separate executables). One that does range image processing and another which receives inputs from the first node and perform gtsam operations. However, it would be preferable to have both operations being performed in one single ros node (one single executable) to avoid any delays and packet buffers if there is speed mismatch between the range image processor ros node and the gtsam optimization ros node.

Any help here would be greatly appreciated!

Reagards, 
Rakshith Vishwanatha




José Luis Blanco-Claraco

unread,
Oct 27, 2021, 12:37:50 AM10/27/21
to Rakshith Vishwanatha, gtsam users
If you are building GTSAM from sources, this *likely* is due to GTSAM
not using the same Eigen version and/or memory alignment than PCL.
Rebuild GTSAM with CMake variables:
- GTSAM_USE_SYSTEM_EIGEN=On
- GTSAM_BUILD_WITH_MARCH_NATIVE=Off
and check if the error goes away... Those are the most common usual suspects.

JL
> --
> You received this message because you are subscribed to the Google Groups "gtsam users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gtsam-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/gtsam-users/e45d6d6d-f43c-4f8c-a925-ecb2ac2827c7n%40googlegroups.com.



--

/**
* Jose Luis Blanco-Claraco
* Universidad de Almería - Departamento de Ingeniería
* [Homepage]( https://w3.ual.es/~jlblanco/ )
* [GH profile]( https://github.com/jlblancoc )
*/

Rafael Spring

unread,
Oct 27, 2021, 6:13:24 AM10/27/21
to Rakshith Vishwanatha, gtsam users
If you're using clang or MSVC, you have a tool called Address Sanitizer. Just compile in debug with -fsanitize=address. That should give you more info where the problem is originating from.

Rafael Spring
CTO, Co-Founder
DotProduct LLC / DotProduct GmbH


On Wed, Oct 27, 2021 at 12:59 AM Rakshith Vishwanatha <rvis...@asu.edu> wrote:

Rakshith Vishwanatha

unread,
Oct 27, 2021, 3:13:34 PM10/27/21
to gtsam users
Thank you for the suggestion. I will give this a try and update the thread depending on what happens.

Rakshith Vishwanatha

unread,
Oct 27, 2021, 3:20:43 PM10/27/21
to gtsam users
Thank you for the input. I will take a look into Address Sanitizer if recompilation based on Jose Luis Blanco-Claraco's suggestions does not solve the issue. 

I am currently using gcc and it looks like Address Sanitizer can be used with gcc as well: https://stackoverflow.com/questions/37970758/how-to-use-addresssanitizer-with-gcc

Rakshith Vishwanatha

unread,
Nov 8, 2021, 1:53:23 PM11/8/21
to gtsam users
Update on the issue: Re-building gtsam using "cmake -DGTSAM_BUILD_WITH_MARCH_NATIVE=Off .." resolved the issue. 

Side note: There was a version mismatch between the system's and gtsam's Eigen libraries. This did not seem to cause the problem however, and use of the GTSAM_USE_SYSTEM_EIGEN=On flag had no effect on runtime behavior my code. 
(The file "...Eigen/Eigen/src/Core/util/Macros.h" was used to check the version of Eigen)

Regards, 
Rakshith Vishwanatha
Reply all
Reply to author
Forward
0 new messages