geometry2 icon indicating copy to clipboard operation
geometry2 copied to clipboard

tf2_ros: add virtual destructor to tf2_ros::BufferInterface

Open meyerj opened this issue 7 years ago • 1 comments

Class tf2_ros::BufferInterface did not define a virtual destructor, but has virtual methods. This is dangerous because it may lead to memory leaks if instances are deleted using a pointer to the base class (reference: https://stackoverflow.com/questions/1123044/when-should-your-destructor-be-virtual).

Clang and GCC with -Wnon-virtual-dtor or -Weffc++ warn about this:

include/tf2_ros/buffer_interface.h:48:7: warning: 'tf2_ros::BufferInterface' has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]                                                             
class BufferInterface                                                                                                                                                                                                                  
      ^                                                     

meyerj avatar Nov 22 '18 00:11 meyerj

This looks right, but I believe it will break ABI so we'll need to evaulate whether an ABI change or memory leak is worse. In general since we rebuild everything right now I think the ABI change is likely less of an issue.

The CI is pending a buildfarm upgrade: https://status.ros.org

tfoote avatar Nov 22 '18 02:11 tfoote

This PR is targeting a EOL distribution melodic, closing this PR, feel free to reopen this against a maintained branch

ahcorde avatar Feb 02 '24 14:02 ahcorde

This PR is targeting a EOL distribution melodic, closing this PR, feel free to reopen this against a maintained branch

Done: https://github.com/ros/geometry2/pull/560

meyerj avatar Feb 03 '24 00:02 meyerj