Cannot delete octomap::OcTree object

asked 2019-05-07 15:14:16 -0600

erdanielx gravatar image

updated 2019-05-08 04:33:12 -0600

I am currently working with the octomap library in ROS to provide mapping capabilities for a SLAM solution I am working on. I am developing a particle filter, and for each particle, I would like to have a different map. I do this by keeping an octomap::OcTree *octo_map as a member of the particle class. On all constructors of the class, I call this->octo_map = new octomap::OcTree(0.5) (where 0.5 is just a parameter for the resolution). Naturally, in the class destructor, I call delete this->octo_map. The program compiles correctly and it gives me no warnings (I added the lines find_package(octomap REQUIRED) and include_directories(${OCTOMAP_INCLUDE_DIRS}), as well as the dependencies octomap_msgs and octomap_ros in the find_packages() declaration to the 'CMakeLists.txt').

During the program's execution, everything works fine up until the moment when it receives a 'SIGABORT'. I debugged this and found that this happens when the delete is called on the OcTree for trying to deallocate an invalid pointer (this code is part of the library, it doesn't happen inside my own code).

This is what I get when running gdb:

*** Error in `/home/daniel/Jacobs/Thesis/ros_ws/devel/lib/bt_particle_filter/bt_particle_filter': free(): invalid pointer: 0x0000000006a0c300 ***

Backtrace:

    (gdb) backtrace

#0  0x00007ffff58f0428 in __GI_raise (sig=sig@entry=6)

    at ../sysdeps/unix/sysv/linux/raise.c:54

#1  0x00007ffff58f202a in __GI_abort () at abort.c:89

#2  0x00007ffff59327ea in __libc_message (do_abort=do_abort@entry=2, 

    fmt=fmt@entry=0x7ffff5a4bed8 "*** Error in `%s': %s: 0x%s ***\n")

    at ../sysdeps/posix/libc_fatal.c:175

#3  0x00007ffff593b37a in malloc_printerr (ar_ptr=<optimized out>, 

    ptr=<optimized out>, str=0x7ffff5a48caf "free(): invalid pointer", 

    action=3) at malloc.c:5006

#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0)

    at malloc.c:3867

#5  0x00007ffff593f53c in __GI___libc_free (mem=<optimized out>)

    at malloc.c:2968

#6  0x00000000004e13e5 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::deleteNodeRecurs (this=0x79bed0, node=0x6a0c300)

    at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:676

#7  0x00000000004e13a0 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::deleteNodeRecurs (this=0x79bed0, node=0x7b59d10)

    at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:669

#8  0x00000000004e13a0 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::deleteNodeRecurs (this=0x79bed0, node=0x75ec980)

    at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:669

#9  0x00000000004e13a0 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::deleteNodeRecurs (this=0x79bed0, node=0x7cffd0)

    at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:669

#10 0x00000000004e13a0 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::deleteNodeRecurs (this=0x79bed0, node=0x73019e0)

    at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:669

#11 0x00000000004e13a0 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::deleteNodeRecurs (this=0x79bed0, node=0x4aab870)

    at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:669

#12 0x00000000004e13a0 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::deleteNodeRecurs (this=0x79bed0, node=0x5362bd0)

    at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:669

#13 0x00000000004e13a0 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::deleteNodeRecurs (this=0x79bed0, node=0x61812b0)

    at /opt/ros/kinetic/include/octomap/OcTreeBaseImpl.hxx:669

#14 0x00000000004e13a0 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::deleteNodeRecurs (this=0x79bed0, node ...
(more)
edit retag flag offensive close merge delete

Comments

1

Please don't use images to display text. Images are not searchable and cannot be copied and pasted. Please update your question with a copy and paste of the text using the preformatted text (101010) button. See the support page

jayess gravatar imagejayess ( 2019-05-07 18:29:17 -0600 )edit

Thank you for the advice! I have updated the question.

erdanielx gravatar imageerdanielx ( 2019-05-08 04:36:12 -0600 )edit