Skip to content

address sanitizer complains new-delete-type-mismatch over allocator_common #2045

@tsingakbar

Description

@tsingakbar

Bug report

Required Info:

Steps to reproduce issue

build humble according to official guide enabling address sanitizer, like this:

colcon build --packages-up-to examples_rclcpp_minimal_publisher --cmake-args -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=OFF -DCMAKE_C_FLAGS="-fno-omit-frame-pointer -fsanitize=address" -DCMAKE_CXX_FLAGS="-fno-omit-frame-pointer -fsanitize=address"

Then launch the shipped example after source installed setup.bash:
RMW_IMPLEMENTATION=rmw_fastrtps_cpp ASAN_OPTIONS=detect_leaks=0 install/examples_rclcpp_minimal_publisher/lib/examples_rclcpp_minimal_publisher/publisher_lambda

Expected behavior

no address sanitizer problems.

Actual behavior

Then address sanitizer reports new-delete-type-mismatch, which is always related to https://github.com/ros2/rclcpp/blob/humble/rclcpp/include/rclcpp/allocator/allocator_common.hpp#L67 .

template<typename Alloc> void * retyped_allocate(size_t size, void * untyped_allocator);
template<typename T, typename Alloc> void retyped_deallocate(void * untyped_pointer, void * untyped_allocator);

Mostly retyped_allocate is called with a size greater than 1, but later calling retyped_deallocate will internally always use 1 as size to dealloc.

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions